Artisan is Laravel's command-line tool used to perform various tasks.
Create Custom Artisan Command:
Create a command:
php artisan make:command GoodMorningCommandapp/
└── Console/
└── Commands/
└── GoodMorningCommand.phpapp/Console/Commands/GoodMorningCommand.php
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
class GoodMorningCommand extends Command
{
// Command name
protected $signature = 'good:morning';
// Description
protected $description = 'Display Good Morning Message';
// Command logic
public function handle()
{
$this->info("Good Morning!");
}
}Run Command:
php artisan good:morningA custom Artisan command is a command created by the developer to automate application-specific tasks. It is created using php artisan make:command, the logic is written inside the handle() method, and it is executed using php artisan <command-name>.