There’s only 3 steps required to setting up new Artisan command.
- Step 1 – Create a new console file
php artisan make:console CommandName
- Step 2 – Open up
app/Console/Commands/CommandName.phpand update the signature and the description property.
/** * The name and signature of the console command. * * @var string */ protected $signature = 'env:db'; /** * The console command description. * * @var string */ protected $description = 'Configure database settings';
- Step 3 – Register your new Artisan command in
/** * The Artisan commands provided by your application. * * @var array */ protected $commands = [ // CommandsInspire::class, CommandsDatabaseEnvironment::class ];
Now you’re ready with your new artisan command. Check your command with
php artisan. It should have something like this one.
Here the a sample code.