示例:
1: 定义自己 Commands类
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use App\Http\Controllers\xxx\xx;
class xx extends Command
{
protected $signature = 'xx:xx';
public function handle()
{
$obj = new xx();
$obj->method();
}
}
2:控制台输入
php artisan xx:xx
问题:如何程序自动调用了 handle 方法 ???
追加问题:handle 和 fire 区别???
自动调用
handle和fire是一个方法. handle是symfony/console/Command里面的, laravel不喜欢用, 就改成fire了.
laravel5.5把fire改成handle了.