This package adds artisan app:install
command, which runs defined commands related to the current environment
Via Composer
$ composer require zfort/laravel-app-installer
Now add the service provider in config/app.php file:
'providers' => [
// ...
ZFort\SocialAuth\InstallerServiceProvider::class,
];
Run artisan make:installer
command to create installer config in app
directory
You can override config key where stored current environment, just publish config file, and set env_config_key
value
php artisan vendor:publish --provider="ZFort\AppInstaller\InstallerServiceProvider" --tag=config
By default it set to app.env
InstallerConfig contents:
namespace App;
use ZFort\AppInstaller\Contracts\Runner;
class InstallerConfig
{
public function production(Runner $run)
{
return $run
->artisan('key:generate')
->artisan('migrate')
->external('npm', 'install', '--production')
->external('npm', 'run', 'production')
->artisan('route:cache')
->artisan('config:cache')
->artisan('optimize')
->external('composer', 'dump-autoload', '--optimize');
}
public function local(Runner $run)
{
return $run
->artisan('key:generate')
->artisan('migrate')
->external('npm', 'install')
->external('npm', 'run', 'development');
}
}
You can add any another method which called the same as your environment name, for example staging
and define different commands
If you need to run commands with root privileges separately you can define method with next convention
namespace App;
use ZFort\AppInstaller\Contracts\Runner;
class InstallerConfig
{
public function local(Runner $run)
{
return $run
->artisan('key:generate')
->artisan('migrate')
->external('npm', 'install')
->external('npm', 'run', 'development');
}
public function localRoot(Runner $run)
{
return $run
->external('service', 'php-fpm', 'restart')
->external('supervisorctl', 'reread')
->external('supervisorctl', 'update');
}
}
Run it by passing "root" option - artisan app:insstall --root
If you want to move config file from the app
directory to a different place, just add a new binding in the AppServiceProvider
$this->app->bind('project.installer', \AnotherNameSpace\InstallerConfig::class);
####List of commands available to run
$run
->artisan('command', ['argument' => 'argument_value', '-param' => 'param_value', '--option' => 'option_value', ...]) // Artisan command
->external('command', 'argument', 'argument_value', '-param', 'param_value', '--option=option_value', ...) // Any external command
->callable('command', 'argument', ...) // Callable function (like for call_user_func)
->dispatch(new JobClass) // Dispatch job task
->dispatchNow(new JobClass) // Dispatch job task without queue
Please see CHANGELOG for more information what has changed recently.
$ composer test
Please see CONTRIBUTING and CONDUCT for details.
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
ZFort Group is a full-scale IT outsourcing service provider that has delivered premium web development, consulting and B2B solutions since 2000.
The MIT License (MIT). Please see License File for more information.