23

Please. Does anybody know why Lumen's team removed the command php artisan serve? That command was very helpful !.

2

5 Answers 5

93

Why don't you use PHP's built-in web server which comes out of the box when you install PHP onto your computer?

Just get into the root directory of your Lumen app and type the following, so your project will be served locally.

 php -S localhost:8000 -t ./public

Note: This PHP built-in web server is intended only for Development environment.

1
17

Alternatively, you can try changing into the public folder of your Lumen application and running php -S localhost:8080. This definitely works on OS X - not sure about other platforms. You can also listen on port 80 but you will need to invoke the command with admin rights.

Although PHP's built-in web server was only added at version 5.4, Lumen requires PHP version 5.5.9 or higher, so this solution should work.

14

I don't speak for Taylor, but my guess is that his reasoning is that a given microframework should not know - or care - about the server that's running it. A microframework should just assume that it's going to work, and leave it to the developer to figure out which tools are best to make that happen.

Laravel is different, in that it offers a more "complete" - and highly opinionated - set of tools to get your web application off the ground. In a full-stack framework, it's not uncommon to provide at least a simple PHP server script.

So with that in mind, it shouldn't be too hard to bootstrap Laravel's own server implementation and artisan commands into your Lumen app.

If you really want to use the php artisan serve command rather than something a little more configurable like Vagrant, you can probably just copy Laravel's server.php into the root of your Lumen application, and then register Laravel's own Serve Command into Lumen.

You'll probably have to change line 42 for your base path, but aside from that, it should be pretty easy to port over.

2
  • Thanks for the answer! I understood what you want to say but I think command php artisan serve very helpful for the developers and one thing the Team didn't see about remove that command in release note.
    – vanhonit
    Jan 10, 2016 at 7:22
  • Apart from giving you the direction you need for putting it back in place yourself, there's not much I can do about that. If you look at the links I sent you, the serve command is really just a very simple wrapper around PHP's built-in server, so you're free to put it back into place on your own. You're also free to open a pull request or check the forums. If this answers your question, then please mark this as answered.
    – maiorano84
    Jan 10, 2016 at 18:03
5

You can find a very lightweight Composer package to add artisan serve to your Lumen app https://github.com/mlntn/lumen-artisan-serve

2

There is a lot simple solution that i had tried. You can simply use php composer package flipbox/lumen-generator with the following command.

composer require flipbox/lumen-generator

Then register this package in your app/bootstrap.php file as

$app->register(Flipbox\LumenGenerator\LumenGeneratorServiceProvider::class);

Thats all! You can use php artisan commands to make resources (controller, models) and **

you can also use the php artisan serve command

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.