Laravel localhost server not working on ios devices - php

I host my laravel project using my network ip address and it's working using android phone, but when i use ios device the page is accessed but only blank display.
What is the problem for this situation and how to solve it?

Related

My ionic app wont connect to a MYSQL database running on the phone but on the PC with localhost it will run

I made an ionic app with a connection to MYSQL using a PHP API which I put on another computer on Xampp, using it as a remote server in the same network, when I run it on the computer with ionic serve , it works fine but when I generate the APK, it wont connect to the BD, even tho Im on the same network, does someone knows any way around this?
this is how it looks on the desktop
and this is how it looks on the cellphone
What I would conclude is that it connects to the nodejs server ("ionic serve") to load the assets from there but it cannot load data from the php/mysql API.
How did you reach the conclusion that MySQL is the problem? I mean your frontend (angular) does connect directly to MySQL right?
Hint: check your settings within ionic when you call the API -- it should point NOT to localhost/127.0.0.1 but to your computer's network IP. Apache should also be "open" to connections from "outside":
see here: Accessing localhost (xampp) from another computer over LAN network - how to?
I had the same problem in the past, it is because when you run the application on your pc it is working on localhost, just like your backend. When you run your application on a mobile device, it does not have access to your pc using localhost to access the backend.
In this case you must set the IP that your pc has on your local network as the backend address and in this way your mobile application can access it

react and php and mobile

I am using react for my frontend, PHP and MySQL for the backend. React is running on localhost, port 3000 and xampp server is in localhost, port 80.
I am getting data from MySQL to php parse to json format. For the frontend, I used axios API to call the data.
While I am in browser, I am able to see the data, but when I access the same page from mobile, I can see only the tables not the json data.
Its probably because you are running your application locally, and wont be able to access localhost on your mobile (because as the word itself suggests its LOCALhost). If your mobile is on the same network as your desktop you can access the site from your computers local ip address.
I guess your front-end is configured to use http://localhost as the back-end url ? Which means that when running on your phone, its using the phone host as the back-end url :)
Try setting the back-end url to http://192.168.1.99 on the front-end.
Change API url to:
http://192.168.1.99/assets/data.php
You used localhost/assets/data.php, but your xampp was installed on your PC, not on your mobile, so your mobile can't access to this.
Hi to test it on mobile you could also used Remote Device from chrome developer tools.
For details you can check on this Link
https://developers.google.com/web/tools/chrome-devtools/remote-debugging/webviews

Ionic on Mobile + MySQL Server + PHP (XAMPP) on PC

Hi I am currently learning Ionic Framework for hybrid mobile apps and I want to connect it to localhost server (XAMPP).
I am developing Ionic App on my PC through ionic start myApp blank and ionic serve.
I have a php file on my htdocs folder in XAMPP which serves as a server-side function to call/query in my MySQL database.
Well, it goes well in development saying that I am working Ionic App on my PC where XAMPP also installed.
But, when I try to ionic cordova build my Ionic App for debug deployment as APK file and install the APK on my Mobile device it is not working.
Well, I know the reason why.
because of the link in my codes: var link = 'http://localhost/api.php';
My questions:
How can I access the PHP file inside localhost server XAMPP
on my PC when my Ionic App is already APK and installed on my
Mobile Device?
Can I use my PC IPv4 address (saying that PC and Mobile are connected
on same WIFI) instead of localhost in var link?
I hope someone can give me a light on my dark room.
Thanks in Advance
I got a way on how to connect to my PC localhost web server.
First, I tried to connect to my WIFI IPv4 Address using the command ipconfig on cmd. And I tried to connect to it, then it was a success. I was able to connect my Mobile App to my PC Localhost web server (XAMPP). But the problem is, whenever the WIFI restarts, the WIFI IPv4 Address changes because of my WIFI DHCP(from what I read).
So, I came up with a another solution to that. I set my WIFI IPv4 address in my PC's Control Panel/Network and Internet/Network Connections and edit the WIFI IPv4 Address, instead of automatically assigned, I changed it to static. Whenever my WIFI device restarts, it does not change my PC WIFI IP address.
So, that's how my problem solved. But I think there will be a problem sooner when theres a same WIFI IPv4 address assigned to other connected device on the WIFI. But, it is okay for now. I am glad that I can access my MySQL database on XAMPP in my PC from my Mobile Device and able to query data.
Thanks. I hope this can solve the problem of other people who has similar problem of mine. Happy coding.

Print HTML/PHP using WAMP on Lan

I have installed WAMP on Computer whose IP is 192.168.1.1 and Printer is connected to same Computer
using USB.
And have configured WAMP so that my Android Device can access Server (WAMP) through WiFi,
i.e. http://192.168.1.1/myproject/print.php
My Android device ip is 192.168.1.2
What i want is to print data which is fetched from DB using PHP file, through Android device directly.
Please help me solving this issue.
You could start by looking at the docs for printing
http://developer.android.com/training/printing/index.html
However you should at least attempt to create an application and post this code to Stackoverflow for better feedback

connect app to php server on localhost

how can i connect an android app (on my phone) to a php server (EasyPHP) that i am running on my machine (localhost). Are there any tutorials out there that document this.
I need to test the app on an actual phone not an emulator (because the emulator contains bugs for certain activities). Any help would be great!
If you connect on your Android with WiFi, you will be in the same network, then you can access PHP server via your machine's IP address.
Ys you connect to the php script...
Android allows you to sent data in GET and POST method..
I found a useful tutorials about this: Android phpMysql connection

Categories