Let's say I'm developing application on my laptop. I have connection to the localhost, and created database. Will I be able to store, or extract data when I run my application on my phone? The phone is not connected to the laptop.
Yes:
Your phone and laptop connected to same LAN (minimal example: set your phone as router with mobile hotspot and connect your development laptop to it).
In other words simply connect the phone and PC running the server to the same local network.
if you have puplic ip you can even let others test your app and connect to your pc as server (preferred static but dynamic will work as well but you have to monitor it and change it in your app every time it changes but most of the time it stays for hours if its not a moving mobile).
Edit:
For php apps you can install a php server in your android phone like Palapa Web Server (tested) and then in your app just make your calls to local address.
Related
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
I have a MacBook and I am currently working on a web-app for our school. I am using PHP, MySQL, and Apache, all provided through the XAMMP stack.
When testing the website via localhost it works fine. Now, some of my teachers wanted to try out the web-app via their phones. Can I configure my MacBook to work like some sort of a 'local server' (e.g. probably through the internal network) to which other devices on the same internal network can connect via their phone browsers?
Is this possible?
You need to understand in using a Website, the client itself doesn't need to contact the database server. The web server is the one who communicate with database server and send/serve html pages to the client.
Phpmyadmin is a website not a database itself. So you simply need to allow access to your web server,you can use your laptop as web server. Test directly using your laptop as a web server, open the website instead using localhost change it to your laptop ip address. If it's not working then tell us the error so we can help you from there.
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.
I have android program to display the sensor data and on button click it will send to local MySQL database running with PHP as backed in wamp server.its working properly.to connect to database i have given local host or local IP address of the system which is running. now i want to send the data to same database on button click with any network connected ? what should i do ? I even tried change allow access to all edit alias in wamp server but unable to connect. so any one suggest what to do?
thanks in advance
Make sure your android app and the computer on which your php code is running are all in the same network. To do this all you can do is create wifi hotspot using one of the devices and connect the other to the same wifi (Create hotspot in your mobile, which is running the app and connect your computer to the same wifi hotspot. Next open command prompt and execute ipconfig. Use the IP address that you got when you connected your computer to mobile hotspot).
OR
You can host your backend code on some servers and use the IP address in your android app(This is more as useful as you can use your android app from any network)
I am developing an application which basically starts with registration system using the wampserver to connect to mysql database through localhost/phpmyadmin as a back-end and android client using genymotion emulator as a front-end and both front and back end communicates through php/mysql API.
I have followed different tutorials to achieve all this but since none of them actually used genymotion I am missing the part of which IP, I should put for this mechanism to follow smoothly.
when you use emulator on you pc , your emulator will connect to virtual network interface that you can change it ....
you should check emulator network interface and enter your pc ip in that network interface ...
i attached a picture of setting of my emulator and you can see my emulator use my wifi network interface .... thus i should insert my computer ip address of wifi network interface
finally you should get your pc ip as network interface that your emulator connected to that and use that ip in emulator for connect to your webserver in your pc.....
in Wampserver, you can not access to apache from outside ...
you should change apache config (httpd.conf) and make access for outside connection ...