How do I add PHP files to my android APK file? - php

I have a web application that uses both localstorage but also server side SQL storage. When I test my APK file using Eclipse only the html pages with localstorage work and not the server stuff in the PHP files. How can I direct my PHP files to go to a server since all the APK does it package everything on the client side?
Thanks

You can run PHP on Android. Try SL4A. Web servers can exist on a mobile. There are quite a few that function as a local server, within Android apps.

You can't run php files on mobile except on the browser
So if you want to run PHP files put them on the server and invoke them to return or accept data from you
To run PHP files you need a web server which doesn't exist on a mobile
I believe that you asked this because you could run javascript & HTML files on the mobile
I will recommend two things
1- If you need to run PHP make ana AJAX request on it and keep it on the server and remember the cross-domain
2- you need to consider the performance of the app you are making because after personal experience its slow
One More thing it works on the chrome because you have a web server (APACHE) on your machine

Related

how to connect my cordova app to an existing web server containing php files

I'm new to working with real web servers
I developed my Cordova app and used PHP files using XAMPP to provide web servers
but now I want to publish the app and I have a fully functional web server
how can I access the PHP files (I already put in this web service) using the POST method (found in my index.js file in my Cordova app)?
I tried changing the URL in the ajax post request
from http://localhost/config.php for example
to http://IP_OF_WEB_SERVER/config.php
but it's giving a connection timeout
how can I get this to work?
Am I missing something?
The question isn't very clear. You can't access your webserver from cordova, or you want to load a php file inside cordova?
The apache cordova doesn't support the usage of php, and another thing is that you can't use the localhost directly. You can use the inappbrowser plugin or ajax to fetch your contents from a remote web server.
In the first case with the plugin, you only need to specify the web address of your webserver that host your app .php files. With ajax instead you need to set some rule of the default content security policy that is shipped when a cordova app is build.

Creating a file in client machine

Is there any possbile solutions in PHP to create a file or directory on the client machine.
Note:
Downloading the file is not a solution to me. only once the user access the website and execute some function and it allows to create a files or directory on the client machine.
Simply, you can't do that in php or any other server side language.
Reason is simple server side application and scripts have access only to local resources where they are launched. So when you run your application on local computer, everything works as you wish for. But because of how HTTP works and because of safety reasons you cannot access user local files.
No it's not possible , except- Flash, Applet ( Not sure ), Microsoft Silverlight ! and for those you will also have to give permission. But i don't think it is a good idea to store file on client machine, try another :)

Do I need to install PHP, MySQL, and something like XAMP, if I already have an IDE, a webhost, and FTP client?

It seems like there are two ways to go, and the determining factor is whether you want to host on your own computer, or through a webhost.
If I have an IDE, a webhost server I subscribe to, and an FTP client to transfer my files to the server, then I don't need to install PHP, MySQL, and XAMP, right?
I know XAMP allows me make my computer website server.
When I install PHP, am I installing the intepreter for my computer/server to parse the .php files? (and same for MySQL?)
If I pay for web hosting, then their servers already have PHP and MySQL parsers, and all I need to do is upload my text files, right?
Thanks in advance
U just cant simply put the files in server without developing them.and if you want to develop any website or any webapp then u need to make your system a local server where you can execute your server side languages like php.XAMP is a short form for mysql,apache and php for windows.and 'website server' is not the proper word.use LOCALHOST instead because only u will have access to your server unless you are connected via LAN or WAN.so i can summarize the above in few points keeping in mind that you want to develop your website.
step 1:install XAMP
step 2:develop and test your scripts.
Step 3:if everything works fine than host your site in the webserver for everybody to see it.

How to make a php file in bluehost that is reachable from ios app and mysql

I have already made my app so that it works on the ios simulator and a localhost server. Now I want to make my app so that it is reachable on ios devices. I have a website that is hosted by bluehost. If I could just write up the same php files that I wrote in the local server and it was reachable from the app and mysql, I think it would do the trick. Unfortunately, I don't know how to do this. Is there a way to access my website's mysql from my ios app through php files (which are also on bluehost)?
Thanks in advance!
You need one of the three (well you can make your own mode as well, but these are standard)
JSON
XML
CSV
Your php file on bluehost would be an URL which would open a stream and push information from the database and your IOS app needs to read it.

GWT frontend (hosted mode) & PHP backend (apache) simultaneously on localhost?

Being a GWT newbie, I want to create GWT frontend and a PHP backend, communicating via JSON.
The GWT Getting started docs (http://code.google.com/intl/sv-SE/webtoolkit/doc/latest/tutorial/JSONphp.html) suggests
compiling the GWT frontend, and
moving it to an Apache/IIS server
Is there a way to avoid this roundtrip?
Could Jetty and a localhost Apache be set up to run simultaneously so that GWT frontend development (hosted mode) could be done in parallell with PHP backend dev?
Alternatively, could GWT Host mode be setup to use localhost Apache/Tomcat instead of Jetty?
Yes it's possible. You have to do the following:
compile once the gwt project and copy it to the php server (you can compile directly to the php server -war option
run dev mode with the -noserver option (this way you won't use the embedded jetty server)
make sure your php project loads the appropriate gwt host file
you should have the apache/IIS server running while in dev mode.
set the appropriate url in the gwt run configuration (if you use eclipse) to load the page with the hosted file on your apache server
Browsers pages (javascript) are normally only allowed to communicate to their origin servers. There are ways around it, but require changing your html pages, which makes no sense since you only need this for developments.
A better solution would be to just copy necessary files to your PHP project directory after every GWT compile. Ant can do this and your IDE maybe too.

Categories