'Command "serve" is not defined (Lumen-Laravel)
So, i try to install the lumen restful api. Based on tutorial, i have to "serve" on php artisan. The command be like:
php artisan serve sample_api sample_api/public
then it shows:
Some say that serve command has been deleted in laravel 5 (which i use it). if so, what command should i use? or maybe find another tutorial?
Ps: Im a newbie :)
Thanks a lot!
Solution 1:[1]
You can use
php -S localhost:8080 -t public/
Solution 2:[2]
This command was removed from Lumen 5.2. You can use any other web server to run your app. I'd recommend to learn Homestead with built-in environment. If you're newbie, you can use something like WAMP.
Solution 3:[3]
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
toApp\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.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Oussema Chaabouni |
Solution 2 | Alexey Mezenin |
Solution 3 |