Using mobile device to access to Laravel local environment

Other than setting up virtual host on your development server by Apache or Nginx configuration ( which you can find the guide here ) Sometimes you should find need to access to your local environment by mobile device. The virtual host no longer provide you such setup.

Using Laravel artisan and PHP built-in server

Simply running 
php artisan serve --host 0.0.0.0
This command will set up a PHP built-in server and will listening to the default port of 8000 to avoid any conflict, so if your ip address is 192.168.1.1, you can access your local environment via mobile device by 192.168.1.1:8000

However if you wish to listen to the Http default port of 80, you can also define as by adding 1 parameter into it, still you need to make sure no other server is running on that port.
php artisan serve --host 0.0.0.0 --port 80
Now you can access by simply typing in the ip address of : 192.168.1.1

*Note: If you use MacOS, you can find out your ip address by accessing System Preferences / Network and look at the wifi ip address.
If you liked this article

Let's subscribe the updates of Scuti!
Share on Google Plus

About Pham Tuan Anh

This is a short description in the author block about the author. You edit it by entering text in the "Biographical Info" field in the user admin panel.
    Blogger Comment
    Facebook Comment

0 Comments:

Post a Comment