use Illuminate\Console\Command; class MyCommand extends Command { protected $signature = 'my:command {name : The name of the command}'; protected $description = 'Description of the command'; public function handle() { // Implementation of the command } }
Artisan::command('my:command', function () { // Implementation of the command });This example shows how to run a command `my:command` without creating a new class. The command logic is passed as a closure to the `Artisan::command()` method. The `Command` option belongs to the `Illuminate\Console` package, which is a part of the Laravel framework.