Gabotronix's avatar

Serve multiple laravel apps on localhost with php artisan serve

Hi everybody, I'd like to be able to serve more than one laravel app at the same time on different tabs/ports, this is so I can showcase various designs, sadly when I run php artisan serve I can get only one app running at a time on port 8000.

Even after updating to laravel 5.8, form the docs:

Artisan Serve Improvements
In previous releases of Laravel, Artisan's serve command would serve your application on port  8000. If another serve command process was already listening on this port, an attempt to serve a second application via serve would fail. Beginning in Laravel 5.8, serve will now scan for available ports up to port 8009, allowing you to serve multiple applications at once.

Is there anything I'm missing?

0 likes
6 replies
rawilk's avatar
rawilk
Best Answer
Level 47

Have you tried specifying the port when running the command?

php artisan serve --port=8001
2 likes
siangboon's avatar

As wilk_randall mentioned that you can use the parameter --port=<<port_number>> when running php artisan serve, beside you can use --host=<<host_name / host_ip>> as well.

But, if you in machine, you probably may consider Laravel Valet, it is much more easy for you to work on multiple projects.

rawilk's avatar

If you're on windows, you can Laragon which works similar to valet and works really well. I use it for my own development.

Snapey's avatar

note that php's server (the thing behind artisan serve) only handles a single connection at once

This means it is unsuitable for testing api between two websites ( if that is why you want it to serve multiple websites at the same time),

jlrdw's avatar

Just install a wamp stack I use bitnami works perfect.

In previous releases of Laravel, Artisan's serve command would serve your application on port 8000. If another serve command process .....

This is a PHP built in server.

Gabotronix's avatar

I ran:

php artisan serve -port 8001

in my local dev lamp stack and it worked perfectly, I just wanted to see various web designs at once so it's all good, thanks everybody

Please or to participate in this conversation.