Home » Php » php – Laravel custom command not working

php – Laravel custom command not working

Posted by: admin July 12, 2020 Leave a comment

Questions:

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.
How to&Answers:

You also need to register the command in the App\Console\Kernel class for it to be recognized:

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.