Skip to content
This repository has been archived by the owner on May 2, 2024. It is now read-only.

Latest commit

 

History

History
159 lines (123 loc) · 5.16 KB

README.md

File metadata and controls

159 lines (123 loc) · 5.16 KB

Application installation command

Latest Version on Packagist Software License Build Status Coverage Status Quality Score Total Downloads

This package adds artisan app:install command, which runs defined commands related to the current environment

Installation

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

Usage

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

Changelog

Please see CHANGELOG for more information what has changed recently.

Testing

$ composer test

Contributing

Please see CONTRIBUTING and CONDUCT for details.

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

Credits

About ZFort

ZFort Group is a full-scale IT outsourcing service provider that has delivered premium web development, consulting and B2B solutions since 2000.

License

The MIT License (MIT). Please see License File for more information.