Coder Social home page Coder Social logo

laravel-initializer's Introduction

Application installation command

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

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

Installation

For Laravel <= 5.4 - Via Composer

$ composer require mad-web/laravel-initializer:~0.1.0

For Laravel >= 5.5 - Via Composer

$ composer require mad-web/laravel-initializer

For Laravel >= 5.5 - Now add the service provider in config/app.php file:

'providers' => [
    // ...
    MadWeb\Initializer\InitializerServiceProvider::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="MadWeb\Initializer\InitializerServiceProvider" --tag=config

By default it set to app.env

Usage

InstallerConfig contents:

namespace App;

use MadWeb\Initializer\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 MadWeb\Initializer\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
    ->publish([ServiceProvider::class]) // Publish package assets
    ->publish([ServiceProvider::class => 'tag']) // Publish package assets with tag

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

License

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

laravel-initializer's People

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.