Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel custom command not working

Tags:

php

laravel

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.
like image 948
Alan Avatar asked Mar 08 '16 22:03

Alan


People also ask

What is custom command in Laravel?

Laravel is a full-stack framework that offers a lot of artisan commands to automate various actions, like creating a controller, seeding the database, and starting the server. However, when you build custom solutions, you have your own special needs, which could include a new command.

How do I run an artisan command?

To create a new artisan command, we can use the make:command artisan command. This command will make a new command class within the app/Console/Commands catalog. In case the directory does not exist in our laravel project, it'll be automatically made the primary time we run the artisan make:command command.

What is tinker in Laravel 8?

Laravel Tinker allows you to interact with a database without creating the routes. Laravel tinker is used with a php artisan to create the objects or modify the data. The php artisan is a command-line interface that is available with a Laravel. Tinker is a command tool that works with a php artisan.

What is artisan command in Laravel?

Artisan is the name of the command-line interface included with Laravel. It provides a number of helpful commands for your use while developing your application.


1 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.

like image 102
Bogdan Avatar answered Oct 16 '22 01:10

Bogdan