Laravel 中使用 PHP artisan xx:xx 命令时,如何调用 Commands 类中的 handle 方法的?
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 区别???
L5.5中
\Illuminate\Console\Command::execute()源码:
L5.5 中已经删除了
fire()
,根据上面的源码。所以只能使用handle()
@lx1036 谢谢你的回答, 对于execute方法 我是不是可以修改了 fire 就可以兼容
@lx1036 对于在控制台 程序是如何触发这个 execute ??? 大佬
@谭重涛
谢谢大佬! 已经了解了。