how PHP use in back end of mobile app development

PHP  is : –

  • PHP is a server side scripting language.
  • PHP can be used in any kind of web application.
  • But the terms comes that PHP can also be used in mobile app development
    Is it right ? Answer is right .
  • But where ? Because all we know that Android Apps developed in Java and Ios Apps developed in objective C and swift .
  • So where and why is the need of using PHP in Mobile App Development.
    And the answer is on server , because alone android app or Ios can not communicate to the server itself .
  • Its need a scripting or server side language for Data manipulation.
  • Here the PHP comes in light so we can use PHP as Back end in App development.
  • But the data manipulation is not the only reason to use PHP ,because android also its internal database .
  • Using web services in back end, make the app smoother and complex logic can easily implement in back end without making the app slower.
  • And PHP is perfect option for writing the code of server side script.
  • We can make web services in Core PHP as well in any Preferred PHP framework.

Here we will take the example in Codeigniter to developed the web service.

Basic Workflow of Web Services :-

* Make a function and returns some value by back end.
* Hit the url from app of  back end function and used the return value in app.

Let an example to make a API or web service to list all the users in app

* Installed the codeigniter and make the project name web_api

Check for installation

* create a new controller called Users 

Check for Controller

* make a function called listing_users in Users controller

the Users controller will look like this
defined(‘BASEPATH’) or exit (‘No direct script access allowed’);

class Users extends CI_Controller
public function listing_users()


Now create database and make table called users and insert some dummy data

now update the listing_users function like this .
class Users extends CI_Controller
public function listing_users()
$response = array();  // blank array initialize
$result = $this->db->get(‘users’); // CI function to select all data from table
$response = array(
‘status’ => 1 ,
‘success_message’ => ‘Data found’ .
‘data’ => $result[0]

else {

$response = array(
‘status’ => 0 ,
‘error_message’ => ‘No Data found’ .
‘data’ => array()



Now url of the API or Webservice is :-




Now when the app developer hit above url.
And use the response as per require in the app.

and we can give the same api url to different app developers like for ios ,android ,windows ,hybrid so on …

Means we can use the same api for for multiple plate form.

Check it also