Executing Artisan's serve Command Using a Specific Port

Testing

Committed to the LaraBrain by: wjgilmore (@wjgilmore) at November 23, 2015 11:41 am

To access your Laravel development site on an internal network you'll need to specify a port

If you're not using Homestead (although I recommend doing so), you're probably taking advantage of Artisan's serve command to run your development site using PHP's internal web server. The most basic form of this command looks like this:

$ php artisan serve
Laravel development server started on http://localhost:8000/

This is great when you're accessing the development site on the same laptop in which it's being developed, but what if you want to test it out on your mobile phone? To do so, you'll need to specify the development laptop's internal IP address like so:

$ php artisan serve --host=192.168.2.9 --port=8000
Laravel development server started on http://192.168.2.9:8000/