Although there is no artisan make:command
in Lumen, you can follow this procedure to reimplement artisan serve
, or even use it as a template to create other console commands.
The serve command was removed since Laravel Lumen 5.2, but you can reimplement it manually as it follows:
Get the ServeCommand.php file from Lumnen 5.0, save it to the folder app/Console/Commands
and perform these 2 tweaks:
- Change the namespace from
Laravel\Lumen\Console\Commands
to App\Console\Commands
.
- Rename the function
fire
to __invoke
.
Edit the file app/Console/Kernel.php
to tell artisan the existence of this new command by listing it in the $commands
member, like so:
/**
* The Artisan commands provided by your application.
*
* @var array
*/
protected $commands = [
Commands\ServeCommand::class,
];
After doing that, you should be able to run artisan serve
. Notice that it will be serving a file server.php
from your project root folder. You need to create this file, or change the code to serve something else.