dfurnes / environmentalist
为Laravel应用提供简单安装。
v2.0.0
2021-07-15 15:18 UTC
Requires
- laravel/framework: ^8.0
- vlucas/phpdotenv: ^5.0
README
为Laravel应用提供简单安装。 Environmentalist是一系列便捷工具,用于通过Laravel Artisan创建设置脚本。[Artisan](https://laravel.net.cn/docs/5.5/artisan)。轻松创建环境文件,提示用户输入值(具有智能默认值和自动完成),并运行命令 - 所有这些都不需要编写或遵循冗长的说明。
安装
要安装此软件包,只需使用composer将其添加到您的Laravel项目中
$ composer require dfurnes/environmentalist
用法
Environmentalist本质上是一个PHP特性,它提供了一系列有用的方法,您可以在控制台命令中使用它们来设置项目。
要开始使用它,您需要在Laravel项目中创建一个控制台命令。例如,让我们为我们的项目创建一个新的SetupCommand
。
$ php artisan make:command SetupCommand
在app/Console/Commands
目录中,您应该有一个新的SetupCommand.php
文件。
现在
现在,在这个文件中,您可以在类中使用ConfiguresApplication
特性并导入文件。
namespace App\Console\Commands; use DFurnes\Environmentalist\ConfiguresApplication; use Illuminate\Console\Command; class SetupCommand extends Command { use ConfiguresApplication; /** * The name and signature of the console command. * * @var string */ protected $signature = 'setup'; /** * The console command description. * * @var string */ protected $description = 'Configure your application.'; /** * Create a new command instance. * * @return void */ public function __construct() { parent::__construct(); } /** * Execute the console command. * * @return void */ public function handle() { // Setup code and environmentalist configuration methods used here! } }
请务必设置一个$signature
来定义要运行的命令名称,以及一个$description
来描述它所做的事情。
许可
MIT © David Furnes