Laravel自定义命令不起作用

时间:2016-03-08 22:23:28

标签: php laravel

我用:

制作了一个新命令
php artisan make:console CrawlData

然后我改变了两个变量:

protected $signature = 'make:crawl';
protected $description = 'My crawling command';

问题是我跑的时候:

php artisan make:crawl

输出:

[Symfony\Component\Console\Exception\CommandNotFoundException]
Command "make:crawl" is not defined.

1 个答案:

答案 0 :(得分:15)

您还需要在App\Console\Kernel类中注册该命令才能识别它:

protected $commands = [
    ...
    \App\Console\Commands\CrawlData::class,
];

您可以在Registering Commands文档中了解更多相关信息。

  

app/Console/Commands中的 Laravel 5.5 命令开始是automatically registered