I've developed an android app that interact with my database by using some php scripts (one for each function of my app) that returns a json object with response data.
Now i need to build up a website too that do the same tasks of my app, but i would fix up my server code.
Should i have to maintain my app php scripts separate from website scripts (i'm planning to use some php framework to develop it), or there's a different way to do it?
No! Same script will work for all platforms.
If you follow proper protocols you will be good :)
Use Rest Console or similar tools to test your webservice on browser.
If you are able to get JSON response, then its good for all platform.
If you want to separate out the platforms and devices on server that can be handled by using user agent check at server end.
Related
I have an Android app a Simple form consist of some fields, I also have a Web server using Google App Engine in PHP. I was confused by This, should i send the Data from my Android app directly to my webserver, display the data in web server using local and then later on update thus data in datastore or should i send the data from my android app directly to the datastore and display in my webserver? I'm new with this Android and with this Google App Engine/Datastore, I hardly can't find proper Tutorials on Google App Engine using php. I think only few uses this thing.
Any Suggestion well do.
The typical solution would be to provide an API for your app. I'm not familiar with PHP these days but there are bound to be plenty of REST frameworks that will take care of all the JSON conversion for you.
Your API (assuming it's PHP) can then take care of doing any necessary validation, authentication, performing queries, etc, against Datastore. This may help.
If you're familiar with Java (you're writing an Android app) or Python, you can look at Cloud Endpoints.
If you want a PHP library to access Datastore from GAE, check this out:
https://github.com/tomwalder/php-gds
This probably seems stupid question. But I'm new to ionic apps. I wanted to clear this before development.
Can we build ionic app without API? like we normally do for our website.
Example:
If you go to MySite.com, you will see the site running in php with normal rendering. Would Ionic work same way or it has to go through API Send/Receive request for data handling?
Ionic has no direct requirement on data access. It is built on AngularJS, which is in turn built on Javascript. Best practices would generally have you accessing JSON data from a server by using a mechanism that is Angular aware such as $http, $resource, Restangular, etc.
However, you can execute any javascript based browser command (or even load something like jQuery to perform the data access). However, as soon as you go outside of Angular, then you will have to deal with the additional complexity of making sure the digest cycle is run whenever you have updated values that may be reflected on your view because of data binding.
And, just to be clear, none of this has anything to do with what's happening on the server side. When you are asking about accessing "without API", do you mean accessing HTML files vs. JSON data? Ionic is built to be a SPA (single page application) that is installed on the mobile device and doesn't require internet access to run once it's installed.
Therefore, especially if external/live data isn't required (imagine some type of calculator where you enter values and results can be calculated with just the data in the app on the handset -- without the need for a live server at all), Ionic apps don't REQUIRE access to an external server at all.
You could provide traditional hyperlinks to other html files, but at that point it would no longer be running the packaged/installed files that form the basis of the installed app on the handset and would instead be a web app that is relying on an external server for all views. And, of course, even if it does require access to data from a server, the often massive increase in speed by not round tripping the server with a new HTML page (only a relatively tiny JSON payload in most situations) makes it feel much more like a true native app.
In ionic, the rendering happens on your phone. The server simply provides data. So if you need any data from a server (usually yes) then you need an API.
Ionic is focused on building native/hybrid mobile apps rather than
mobile websites.
– http://ionicframework.com/docs/overview/#browser-support
As per definition, an API only defines the way your ionic app can interact with your php script. In principle, there are no rules on how you design this interaction. So yes, you can keep it quite traditional/old-fashioned. Don't get the concept of an API mixed up with the concepts of RESTful or SOAP APIs etc.
So I've built a web app in PHP that relies heavily on a MySQL database. Now (for user convenience purposes) I'm trying to create the exact same app, just as an iPhone app. Granted, I have no knowledge of Objective-C (just starting to learn it), I wanted to know how to go about this. I know that I'll have to use some kind of intermediary to get Objective-C to connect to the SQL database.
So essentially my questions are: If I've already created the web app as aforementioned, could I use the same DB and tables for the iOS app version as I did for the PHP web version? Also, is there anyway to migrate any code I've created in PHP to iOS (I realize that they are two completely different languages), but I'm just curious as to whether or not I'll have to build the iOS app from 'complete' scratch.
Your best bet is to write an PHP service to talk to your database.
This way you can share this API between your app or iOS app or any other type of client app.
The service will be responsible to receive request query the database and send responses in JSON format for example.
So to make things easier, you should not query the database directly from your apps, use a common web service.
You can use your MySQL database for any purpose because it is just data. The code that will show them will be different though. If you have no knowledge about Objective-C you should consider the web-app approach.
Here are a few helper links.
https://developer.apple.com/library/safari/referencelibrary/gettingstarted/gs_iphonewebapp/_index.html
http://gigaom.com/2010/02/12/how-to-create-an-iphone-web-app/
We have to develop an application with more plattform. We would use the framework PhoneGap. For our application we need services of backend, the question is: Does PhoneGap support PHP?
If it doesn't support PHP. In which way we can solve the problem?
The most important thing is: make call server
(Get and Post), parsing a json and other functions
that PHP gives.
Phonegap does not have a server. You need to call via Ajax to remote servers.
The backend can be in any language which supports HTTP calls, as PhoneGap is an independent client.
You can use PHP to write an API for use within your Javascript PhoneGap application.
I can recommend the Laravel framework to accomplish this.
Yes...you can use PHP or any PHP framework to give backend for mobile app made using phonegap/cordova....point is phonegap/cordova app will be on client mobile which won't understand PHP embedded in phonegap html files....so write an API amd place it on a server and then make AJAX calls to server to do database and other backed operations
Try to return JSON data from the PHP API.....it's a famous data structure and supported by many applications
I want to connect a MySql DB with my android application.
However, I DON'T want to/CAN'T use PHP for doing this.
Almost all solution for MySql connection with android on internet uses PHP.
I read somewhere that, If one don't want to use PHP then web service should be used.
But I'm not able to find any tutorial/sample example for the same.
Any help appreciated.
It seems you're mixing up some things.
A web service is simply some code on the internet (web) which allows you to receive and send information to a server, where it is saved per example in a database.
PHP is just a language, in which you can write a web service.
You can use a vast array of languages to create a web service ( read: expose your database) to other devices. Among others, you can easily do this in Java, .NET, Python ...
If you're looking for a way to connect to an external database without any web service / API in between, i'll have to disappoint you with the news that this is not supported by Android.
Most examples of a simple web service / a bunch of scripts contain PHP since this is probably the easiest and can be used on pretty much any server.
A webservice, is as it's called, a service, meaning that you have one side consuming it (the android client). if all you want is a persistent storage, you could use SQLite which is an SQL compliant solution which exists within android.
If it's possible to SSH to a server via Android, you could use that to connect to mysql, because the only other solution involves having mysql binaries installed locally on your android machine, and that's not possible AS FAR AS I KNOW, on Android.
One major reason for using a webservice (e.g. written in PHP) to connect to a remote DB is that you don't want to store the database login credentials inside your app. Because otherwise it'll be easy to extract your login for that database and access and edit it in a way you might not have planned (eg. delete stuff).
Its Possible to connect mysql database .
I have done with out using php file . I have used an spring configuration file to establish an connection to the database and dao to access the data from the database.
Create an Web Application that access the Server through the Spring Framework and an Servlet .
Create an Android Client Application tat make an get / post request to the Servlet , process the results in the servlet and return the response to the Android Client Application (json format ) Process the json format reponse in the Android Client Side and use it to your application