Can we use PHP in Phonegap Build?

  • 1
  • Question
  • Updated 4 years ago
Photo of Saba Rais

Saba Rais

  • 724 Posts
  • 3 Reply Likes

Posted 4 years ago

  • 1
Photo of JesseMonroy650 (Volunteer)

JesseMonroy650 (Volunteer), Champion

  • 3325 Posts
  • 122 Reply Likes
READ!!!!
FAQ


Q: CAN YOU USE PHP/ASP/JSF/JAVA/.NET WITH PHONEGAP?

A: A PhoneGap application may only use HTML, CSS, and JavaScript. However, you can make use of network protocols (XmlHTTPRequest, Web Sockets, etc) to easily communicate with backend services written in any language. This allows your PhoneGap app to remotely access existing business processes while the device is connected to the Internet.
Photo of Chris Griffith

Chris Griffith, Champion

  • 347 Posts
  • 92 Reply Likes
No, server side solutions will not run locally on the device. You can use PHP to power your remote service that the app can call, but you can not run PHP locally.
Photo of Petra V.

Petra V., Champion

  • 7794 Posts
  • 1391 Reply Likes
Ah. I agree.
That's why I mentioned "(But you will - safely - have assumed that this was not what the OP had in mind) ", when Chris claimed that "server side solutions will not run locally on the device".

Installing a webserver with PHP first is something you would only do for projects in a non-public environment.
Photo of Petra V.

Petra V., Champion

  • 7794 Posts
  • 1391 Reply Likes
BTW: this would be a webserver plugin for Cordova:
https://www.npmjs.com/package/cordova...
I just don't see if a PHP engine is included. It might not interprete PHP.
Photo of jcesarmobile

jcesarmobile

  • 283 Posts
  • 40 Reply Likes
Ah, I missed that one, searched for server and when I saw it I thought it was some kind of fork from cordova-plugin-http. For ios there are a few more, used to workaround some WKWebView issues. But any of them support PHP.
Photo of Saba Rais

Saba Rais

  • 724 Posts
  • 3 Reply Likes
Sir, Chris Griffin but we can use php locally with the help of LOCAL WEB SEVERS Like WAMP, MAMP, XAMP etc?
Photo of Saba Rais

Saba Rais

  • 724 Posts
  • 3 Reply Likes
Then how we can use PHP ? I mean to say that how we can use PHP with html5?
Photo of Petra V.

Petra V., Champion

  • 7794 Posts
  • 1391 Reply Likes
In fact, it is no different from any decently designed MVC based website. In such web application, you would also separate data handling, business logic and presentation.
By now, the times where database requests, application logic and html form/design elements were all packed together in a single PHP document, should be considered history (I hope).
Photo of Saba Rais

Saba Rais

  • 724 Posts
  • 3 Reply Likes
I am using Windows(O.S.) and also using a local webserver WAMP i have also created dynamic websites but my .php files phonegap build can't support.
Photo of jcesarmobile

jcesarmobile

  • 283 Posts
  • 40 Reply Likes
Your .php have to stay on your WAMP server, and you hae to use XHR calls (AJAX) to that server. If you don't know how to do it, google about XHR
Photo of Petra V.

Petra V., Champion

  • 7794 Posts
  • 1391 Reply Likes
Well, it's the device OS that doesn't interprete PHP scripts. Phonegap Build is just the assembler of your .apk/.ipa, not the live environment.

So, you will have to redesign your application in such a way as to create PHP webservices that handle ajax/xhr requests from the app.
Photo of Saba Rais

Saba Rais

  • 724 Posts
  • 3 Reply Likes
Thank You :) now i cud google XHR calls thanks again
Photo of JesseMonroy650 (Volunteer)

JesseMonroy650 (Volunteer), Champion

  • 3325 Posts
  • 122 Reply Likes
@saba,
Are you aware that both Google and Apple frown on apps that are website wrappers?
Jesse
Photo of Saba Rais

Saba Rais

  • 724 Posts
  • 3 Reply Likes
@Jesse i admitted my mistake i have to study much, see u after study :)