简体   繁体   English

Laravel自定义命令不起作用

[英]Laravel custom command not working

I made a new command with: 我做了一个新的命令:

php artisan make:console CrawlData

Then I changed two variables: 然后我改变了两个变量:

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

The problem is that when I run: 问题是,当我跑:

php artisan make:crawl

It outputs: 它输出:

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

You also need to register the command in the App\\Console\\Kernel class for it to be recognized: 您还需要在App\\Console\\Kernel类中注册该命令才能识别它:

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

You can read more about that in the Registering Commands documentation. 您可以在“ 注册命令”文档中阅读有关该内容的更多信息。


Starting with Laravel 5.5 commands in app/Console/Commands are automatically registered . app/Console/Commands中的Laravel 5.5命令开始自动注册

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM