Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Access to Laravel 5 app locally from an external device

I've looked for a solution in the web, but I've not found a solution yet. I need to access to my Laravel 5 app from my iPhone, but I'm in develop, so I don't want to publish my app on a web server.

If you have a link to follow, that you assure it works, It's perfect for me.

Thank you!

like image 241
Bellots Avatar asked Jun 05 '15 20:06

Bellots


2 Answers

If you're not bound to using Apache or nginx for some special reason and this is for development purposes only, you could serve the application using the PHP built-in server and artisan. It's by far the easiest thing to setup, and will only require you to run one command in the Laravel application directory:

php artisan serve --host 0.0.0.0 

The default port it will be listening to will be 8000 to avoid any conflicts, so you can now access the application from your phone via the IP address of your computer:

http://192.168.1.101:8000 

If you want to listen to another port (for example the default HTTP port of 80) you can pass that as a parameter, just make sure no other server is running on that port. So if you run this instead:

php artisan serve --host 0.0.0.0 --port 80 

You can now access your application with just the IP address:

http://192.168.1.101 
like image 168
Bogdan Avatar answered Oct 01 '22 23:10

Bogdan


Its simple, first you have to run the server

php artisan serve --host 0.0.0.0 

Then you need to know what`s your IP address, run this command to get IP:

In windows:

ipconfig 

In Linux:

hostname -I 

For example, my IP is: 192.168.1.68

Once you get your IP, then you have to go to this address on your mobile. Like:

192.168.1.68:8000 

And that's it.

like image 44
Ragabazh Avatar answered Oct 01 '22 23:10

Ragabazh