Access to Laravel 5 app locally from an external device - php

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!

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

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.

There are so many ways to do this.
Access your web via IP address from your iPhone, e.g. http://192.168.1.100/laravel
If your iPhone is jailbroken, you can edit iPhone's /etc/hosts file, the access your website via domain, e.g. laravel.com 192.168.1.100
Upload laravel app to web server and config it a test domain, e.g. dev.domain.com, or dev.domain.com:8080
If you can config your WiFi router, you can give your computer a "port forwarding" or set "DMZ"
Upload your website, and config "IP forbidden" roles, e.g. for Apache, edit your laravel's .htaccess file:
Deny from all
Allow from 180.159.251.175

You can use Laravel Homestead, an official pre-packaged Vagrant "box" to develop your project and access your local website from multiple machines within the same private network.
Here you can find more information about homestead and how to use it:
http://laravel.com/docs/5.0/homestead
And here a sample Vagrant private network setup:
http://docs.vagrantup.com/v2/networking/private_network.html

If you are having trouble using the accepted answers method, and you get page not found or similar errors, this is likely due to your firewall settings.

If
php artisan serve --host 0.0.0.0
doesn't seem to work.
Try php artisan serve --host 0.0.0.0 --port 80.
And access just using your IP address. For instance:
http://192.168.1.101

Related

How to share laravel app in local network

I have developed a laravel application and I want to share this application in my local network to be able to access to this app from any workstation connected to this network.
I'm using EasyPHP-Devserver-17 and the app is working correctly on the local machine (127.0.0.1/app/public). I have changed the phpserve file to add "Listen 10.0.102.2:8080" and once I add this to phpserve file I can access to this address "http://10.0.102.2:8080" from others workstation, but when I go to the laravel app I got this error message:
Not Found
I changed the URL in the following files in the laravel app: app.php, .env and livewire.php, but I still get the same error message.
hello maybe this link will serve you
Access to Laravel 5 app locally from an external device
php artisan serve --host 0.0.0.0 --port 80
"0.0.0.0" is your ip server
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

How to give on local to other pc access to your project in valet?

When I make a project in laravel I can give access with php artisan serve but if a make a normal project and make host with valet link the PHP artisan don't work because it's not a laravel project. How can i give access to local with valet ? For example i have project.dev and make 192.168.1.5:80 like in laravel.
You can use the valet park or valet link commands to be able to access your application locally.
For a local network, you will need to make sure your port is accessible if your're behind a firewall. You may need to setup port forwarding, as well, if NAT is involved.
Are you trying to make the project accessible to others on the internet? For this, you can use ngrok.
https://ngrok.com/
”I want to expose a local server behind a NAT or firewall to the internet.”

Set Laravel application online to whole LAN with domain name

I have developed a Laravel 5.4 application and now I want to put it "online" for everyone in my LAN and also set a local domain name to it, like somedomain.lan, for example. When I run php artisan serve --port=XXXX it starts the application on localhost port XXXX. Given that I'm running a Linux machine, how to make it available this service on port XXXX in such a way that my whole LAN, and only my LAN (not external internet), sees it and also give the domain name?
Open your command prompt, type "ipconfig", look for your ipv4 address. It should be 192.168.xxx.xxx.
Then php artisan serve --host=[your ipv4 address]
Make other computers connected to your network to connect to your application using your ipv4 address. Your ipv4 address define your computer address within current used network.
Not sure will work or not, but i do it this way and it works.
I would recommend you to use Laravel valet
With valet you can say:
Valet share
Then you will get a unique link that can be shared.
Super easy I use it everyday!
With artisan you can set the ip like this:
php artisan serve --host=503.246.895.41 --port=8125

Access Symfony's localhost:8000 on other devices in the same network

I am developing a symfony project on my local machine, I wish to test it on my mobile via IP (both machines connected to wifi network). how do I access port 8000 (symfony's default port) on my mobile phone?
I already know about accessing localhost via IP of the serving device, but I want to access the port too(8000) which I cannot fetch from my devices!
Thanks for all the help
As answered to another Question this might be solved when adding the parameter 0.0.0.0:8000 to let Symfony not only respond to local requests but also accept requests from other devices.
The call then should look something like this:
php bin/console server:run 0.0.0.0:8000
Same way you accessing it from your local machine but using it's IP address e.g.:
http://192.168.1.2:8000
where 192.168.1.2 is your machine IP address in local network (check it using ipconfig command - on Windows or ifconfig on Linux/Mac OS X). Please make sure your firewalls (on local machine and on router) does not block this (8000) port.
UPD: By the way, as far as I remember, Symfony's default port is 8080, not 8000. Please check it carefully.

Cannot connect to Laravel server in Virtual Box appliance

I am trying to implement my first Rest API using Laravel.
I am running Debian on a Virtual Box machine on a Windows host. The network card of the VM is configured to "Host-only adapter".
I am able to reach the phpmyadmin instance on the machine using http://ip-of-the-vm/phpmyadmin. But when I try to reach the Laravel appliance on http://ip-of-the-vm:8000 it does not work. I think the port could be the problem.
Does anybody have a suggestion for how to solve this?
The problem was that laravel was only reachable over localhost. You have to start the server using
php artisan serve --host 0.0.0.0 where 0.0.0.0 should be replaced with the ip of the server.
You can optionally define a port if you want by using
php artisan serve --host 0.0.0.0 --port 80 for example.

Categories