Laravel Artisan Creating and registering new artisan command


You can create new commands via

php artisan make:command [commandName]

So this will create [commandName] command class inside app/Console/Commands directory.

inside this class you will find protected $signature and protected $description variables, it represents name and discription of your command which will be used to describe your command.

after creating command you can register your command inside app/Console/Kernel.php class where you will find commands property.

so you can add your command inside the $command array like :

protected $commands = [

and then i can use my command via console.

so as example i have named my command like

protected $signature = 'test:command';

So whenever i will run

php artisan test:command

it will call the handle method inside the class having signature test:command.