一、下载 laravel 5.5
composer create-project laravel/laravel=5.5.* laravel5.5_command
切换目录
cd laravel5.5_command
二、自动加载 command
创建 command
php artisan make:command SayHello
修改创建的文件:app/Console/Commands/SayHello.php
protected $signature = 'say-hello';
protected $description = 'Hi Boy';
public function handle()
{
$this->info('Hello Boy');
}
执行 help
php artisan help say-hello
执行 command
php artisan say-hello
自动加载代码:app/Console/Kernel.php
protected function commands()
{
$this->load(__DIR__.'/Commands');
require base_path('routes/console.php');
}