double-a/laravel-init

使php artisan init命令使项目初始化变得简单

v1.0.3 2023-11-25 17:31 UTC

This package is auto-updated.

Last update: 2024-09-25 19:25:39 UTC


README

厌倦了反复运行Laravel的命令吗?

您有一组需要按顺序运行的命令来运行应用程序吗?也许是将一些信息种入数据库?

Laravel Init为您提供了一个简单的配置文件,您可以将这些类型的命令放入其中,而不是每次都手动运行,您只需运行 php artisan init

这是它的工作方式

目录

安装

composer require double-a/laravel-init

配置

可以使用以下命令发布配置文件

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

默认配置文件位于 config/init.php,如下所示

<?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,
];

用法

只需运行 php artisan init