Questions about phonegap - php

I built a mobile website using jquery mobile (client side) and php/mysql (server side)
I found phonegap to put it in a native app. But despite many researches, i didnt found the answer for those questions :
how do phonegap loads pages in those two cases :
When the page refreshes without ajax
When a jqm page is loaded and injected with ajax
This question is crucial because if the page is loaded from my server, i would be able to put php into it. If pages are stored and brought directly from the client where the app is installed, I have to remove all php from my pages. On the other side, storing pages on the client would improve drastically the speed of the loading.
The best would be to choose for each ajax call of jqm, by a parameter, whether the first or the second scenario. Controlers written in php and returning json would be loaded from the server each time, but the jqm pages would be stored into the client phone as he download the app.
I have a second question:i ve downloaded the phonegap desktop app but i still dont know how to build an entiere app sendable to the stores. I found several technologies like phonegap build, do you recomand it ? i dont know a word in java..
Thanks for your help and please excuse me if Im wrong with english sometime.

Related

Making a "page change" in a single page web app over a WebSocket using php

I am trying to make a single page web app that runs over a websocket for all server request. After the user logs in, I want the page to change the html to display a dashboard (first page).
I have a template for the dashboard already build from a previous version. I need to find a way to input database info into template and send the page over the websocket as a string for the javascript to display.
I don't know how to fill the template using php classes without hard coding it into the class, then turning it into a string so I can send it. The dashboard is very complex and has dynamically built menus for each users per their settings and permissions.
Am I looking at this whole problem wrong? I have some experience with MVC from ruby on rails/node.js, but unfortunately this app is stuck using php. Can I use a framework with the socket? Should I have the JS load the template through https and send the data over the socket? (The JS guy would not like that).
I am running Ubuntu, apache2, php7, Ratchet WebSocket(wss), composer, and MySQL all on AWS.
I would definitely let the frontend get the required data. You could use php as a backend to test the authentication, parse the request, get the data from the database and send it to the frontend. The frontend then would need to update the application using dom manipulation (think jQuery).
Or, php could send a generated view that would be shown in a div in the frontend.
In this setup, I would not recommend websockets, but just plain AJAX.
From what I gather from your question, you might be better of using a real SPA framework like AngularJS. It it just better in using the data you will get from the backend. You could then choose to use a PHP backend using AJAX or a Websocket backend like nodejs.

How to use Node.js, Express, and Socket.io in a PHP file being served by Apache?

I am working on a project that was written in PHP and being served on an Apache server. I have been asked to integrate Socket.io live chat functionality into a page that was written in PHP and served by Apache. To do this, I've been writing a Node.js application with Express. But I can't figure out a way to integrate my Express app into the PHP page.
I have googled this for several hours and found many tutorials about running Node.js and Apache on the same server but different ports, but as I understand it, that strategy would limit me to serving different pages or different files. What I need is to be able to use the Socket.io livechat function on the PHP page.
I thought maybe I could use an iframe integrated into the PHP page to display the livechat window itself, but I also need to display new chat request notifications on the PHP page and give the user the ability to click different tabs to switch between chat windows. I thought I could probably have the tab clicks handled by writing a REST API on the Node.js end and letting the PHP page make calls to that. But I'm not sure how I would have the PHP page display new chat request notifications if I can't have Express and Apache handling the same page.
So my question is basically how to:
1) Configure things so one PHP page can be accessed and manipulated by both the PHP side and the Node.js/Express side of things, or
2) Route Socket.io events from the Node.js/Express side into the PHP side so that they can be handled on that end.
Context: I know minimal, minimal PHP--that's being handled by my colleagues, and my role is the JavaScript and Node.js stuff--so please keep that in mind.

How to make sure that a PHP page is called from my mobile app

I have an iOS/Android app and I want to convert some of its functionality to webview, as this will make minor changes easier as I will only have to update the web app, rather than updating both iOS and Android and wait the review process.
I already have a PHP-mysql server app and use various server-client communication, so I am adding to this server app the pages I will display in my mobile app webview. The drawback here, is that if I typed the url and passed the same parameters in any browser, it will work, and I do not like that.
How to make sure inside my PHP code, that the page is being called from inside my own app?
Thanks for advance.

Is there any way to use a Joomla site into an app using PhoneGap?

I am new in PhoneGap,
I have a Joomla Site, I want to create a PhoneGap App using that Joomla site. so is this possible ? if yes than how can i implement it ?.
You can use. But you have to create web services for request and responses. Because Phonegap will not run PHP script. So you can create webservices to access Joomla functionality via JSON responses from your joomla. You can get the JSON data via jQuery in your phonegap app.
and someone said PGBuild will convert webpage into phonegap app. You can try it also.
I have succeeded creating an application as follows:
Design your Joomla page so it's responsive and renders correctly on your mobile;
Download the whole thing with wget
Edit all urls and make them point to the right (local-remote) locations.
I saved all css, images, js locally so the page would load even offline; then changed all the links so they point to the remote host;
All forms should point to the remote host;
Most modules and components were changed so after the initial display (local) they will load the updated info in the frame.
Popups won't be available, so you'll need heavy workarounds for facebook integration etc.
Also, if you plan to use any phonegap features, they will only be available if you load the library inside your downloaded page; this will force you to change all calls to ajax (no document.location.href calls are possible since you'll lose the phonegap javascript).
The first time you load the page from the server it will take forever to load. Ensure you have proper caching set up otherwise you'll just lose your customers.
My advice is to start with an ajax project at the very beginning, it will save you lots of headaches.
Keep in mind, if you plan to use iframes, forget it. They work lousily on iphones, and debugging is nearly impossible. Simply take your time to plan a real phone app in javascript & using Ajax for the calls.
You don't need any webservices in Joomla for loading content, simply use:
&tmpl=component
when you need the content of a module.
Additionally, for blogs and lists, Joomla makes RSS feeds available so you shouldn't need too much coding to achieve this.
I have limited myself to ajaxifying the modules, which makes caching more efficient on the server and the interfaces appear more dynamic.

Database record wont show on my mobile application

I use html5 + css3 + jquery mobile to built my mobile application. Actually I've already desktop version, and i want to make mobile application.
Is that true php wont work on html5 for mobile application?
If that true, i use ajax for call my JSON (that place create on jsontext.php).
I tried HTML5 on desktop browser and it worked.
I built it to apk using build.phonegap.com and install the apk to my device.
After that, my database record not showing. Maybe it didn't execute.
Other user in stackoverflow said we can use backbone.js. how-to-access-a-remote-database-from-jquery-mobile-application
are my steps right? or I have to use backbone.js. THX.
Here's some answers:
Yes, php won't work in a mobile native/hibrid mobile application,
because php needs to be interpreted by a php server before
generating output.
Its easy and simple to both generate and parse JSON, it's widely
used in apps.
That is good. If you want an 'online-only' kind of app, you can use
a webview and point it the url of your app - its basically a browser
without navigation buttons and user interface - but something's
don't work that well, you should test before. It may also display
your app as sluggish and unpolished.
No problem with that, Cordova/Phonegap is actually becoming a very
good mobile framework. You should also install ADB
(http://developer.android.com/tools/help/adb.html), ADT
(http://developer.android.com/tools/help/adt.html) and the Android
device emulator
(http://developer.android.com/tools/help/emulator.html).
You must be sure on how to insert and retrieve dabatase records.
This depends on how you programmed it. Be sure to have the database
available publicly (accessible only from the apps, though).
Hope I've answered your questions, and that it helped.

Categories