LaravelPackages.net
Acme Inc.
Toggle sidebar
double-a/laravel-init

Making php artisan init command to make project initializing easy

9
1
v1.0.3
About double-a/laravel-init

double-a/laravel-init is a Laravel package for making php artisan init command to make project initializing easy. It currently has 1 GitHub stars and 9 downloads on Packagist (latest version v1.0.3). Install it with composer require double-a/laravel-init. Discover more Laravel packages by double-a or browse all Laravel packages to compare alternatives.

Last updated

Laravel Init

Tired of running Laravel's command over and over again?

Do you have a set of commands which should run in order to run the application? Perhaps seeding some info into the database?

Laravel Init provides you with a simple config file which you can put these kind of commands in it, and instead of running them manually everytime, you can just run php artisan init.

Here is how it works:

Table of Contents

Installation

composer require double-a/laravel-init

Configuration

Configuration file can be published using the following command:

php artisan vendor:publish --provider="DoubleA\LaravelInit\Providers\InitServiceProvider"

Default configuration file located in config/init.php looks like this:

<?php

return [
    // Default steps that will run, regardless of the chosen option
    // put your custom commands (e.g for running the seeders) here
    "default_steps" => [
        "git pull",
        "composer install",
        "php artisan key:generate",
        "php artisan storage:link",
        "php artisan cache:clear",
        "php artisan config:clear",
    ],

    // you can define as many options as you wish
    "options" => [
        [
            "title" => "Fetch updates and start from scratch (Removes all data)",
            
            // it means a secondary confirmation will be asked from the user before proceeding
            // usefull for operations which can be dangerous like migrate:fresh
            "confirm_needed" => true,
            
            // Any extra command you wish to run only on this option and not on others
            "extra_steps" => [
                "php artisan migrate:fresh --seed"
            ],
            
            // application will not be served after
            "serve" => false,
        ],
        [
            "title" => "Fetch updates and keep going from where you were (No data will be removed)",
            "confirm_needed" => false,
            "extra_steps" => [
                "php artisan migrate"
            ],
            
            // In case of setting serve to true, serve_port can optionaly be provided
            "serve" => true,
            "serve_port" => 8000, // optional - default : 8000 - not required if serve equals false
        ],
    ],

    // false means that the command will stop in case of error
    // in case of true, regardless of any raised exception, next command will be executed
    "continue_on_error" => false,
];

Usage

Simply run php artisan init

Comments