I have a React.js frontend project and Laravel backend project separated. I can access my frontend project via the local host address provided upon running npm start so I can see the frontend on a physical device of what I'm working on.
However - When I try to login (backend functionality) on my physical device, it won't allow me to. php artisan serve's running on my backend project and I can successfully login on the browser without any issues so my login system isn't the issue.
I guess my question is - how can I make it so that my physical device knows that php artisan serve's running so I can access my web app with the localhost address given to me provided by npm start?
In other words - how can I make 127.0.0.1:8000 (php artisan serve) sync up with 192.168.2.165:3000 (npm start)?
I think you want to have your app request proxied to your backend server. take a look at this from Create-react-app doc : https://create-react-app.dev/docs/proxying-api-requests-in-development/
Based on your description you should add this line to your package.json for your react app :
"proxy": "http://192.168.2.165:8000"
I'm working on a project in laravel and to test the site on mobile i have been running the following command:
php artisan serve --host 192.168.83.1 --port 8000
This used to work fine, and still does on my own laptop.
However it suddenly stopped working on my phone and i can't seem to figure out why.
Could their be changes i have made to my laptop that are blocking the route?
Or have i changed something in my project which does not allow for mobile devices?
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
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
I'm doing live chat server on my laravel development, I setup everything in Digital Ocean. Setup apache2 and phpmyadmin. However, when I tried to run the
"php artisan serve"(Default port:8000)
then open up my website with IP. The server commands didn't detect anything. Fine. I try my live chat server
"php artisan chat:serve --port=8887"
with different ports. But didn't work for me, it shows blank screen without errors. Suppose shows me live chat messeger interface on my website but blank. I know something deals to my apache2 server, but I have no idea how to deals with it.
By the way, I'm using emberJS chat server and follow-up this tutorial at here
php artisan serve is intended for local development, and as such, limits itself to the local network by default. Doing php artisan serve --host 0.0.0.0 will allow it to be accessible to the public internet.
Do note that php artisan serve should never be used to serve a production site. You should be serving the live site with Apache, not Artisan.