All Posts

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

Why redirect() not working in laravel 5 constructor

why redirect() is working in routes and methods only.

So for getting the advantage of redirection in constructor, we have to use a special function.


For using the above function we need to add a below line of code in Controller :-

use Illuminate\Support\Facades\Redirect;

Note :- here userLogin our routes name

Check it also

check for the documentation

How ngModel Can’t bind not a known property of input in Angular

For using ngModel ,You should include FormsModule first in your application.

because by default angular does not recognise the “ngModel“.


Steps for adding  FormsModule in your code are .

Open your app.module.ts file.

import the line : – import { FormsModule } from ‘@angular/forms’;

and also add the FormsModule in imports array like this :-

imports: [

Check it also

check for the documentation

Why Parse failed: regular expression in Angular 6

Module parse failed: Unterminated regular expression in Angular 6 ?

Angular throws this error

because the syntax you have used which is not valid in angular 6.

The used syntax can be work for importing “router” in angular 4.

But it will not work in angular 6.

Hence exact syntax is : – import { RouterModule, Routes } from ‘@angular/router’;

update the above syntax ,issue will be resolved.

Check it also

check for the documentation


how to use str_ireplace function in php

str_ireplace function is one of PHP String function .

with the help of this function we can replace the space or something from the string in php with case insensitive effect.

Syntax :-  str_ireplace(find,replace,string,count)

Case insensitive means here str_ireplace function ignore the case and the same for in all case like – WORD,Word,WOrD,WoRD

it will treat all the above word same .Let us take some examples

$our_string  =  ‘Hello SAM’;

And we want to replace the SAM with Ram than we can do this str_ireplace function

$str = str_ireplace(“SAM”,”Ram”,$our_string);

echo $str ; // output is Hello Ram


$str = str_ireplace(“SaM”,”Ram”,$our_string);

echo $str ; // output is Hello Ram


$str = str_ireplace(“SAm”,”Ram”,$our_string);

echo $str ; // output is Hello Ram


$str = str_ireplace(“sAM”,”Ram”,$our_string);

echo $str ; // output is Hello Ram

We can see that in all the case we get the same output .which is a quality of case insensitive of str_ireplace function in PHP.

Check it also

check documentation

why Base table : 1146 ‘database.tables’ doesn’t exist laravel 5

This is the very common error occurs for beginners.

Error is like, the table is not exist which the user wants to use”.

As per the laravel documentation, it is good to make the table name in plurals.

For example you have given the table name is “user” .

But laravel is searching for the table name as “users”, because by the documentation name should be “users” ,that’s why  error is occuring.
So for resolving this we have to define the exact table name in the model as we have given the table name:-

For Example – We have a shayari model class looking like this


namespace App;

use Illuminate\Database\Eloquent\Model;

class shayari extends Model
protected $fillable = [‘cat_id’,’sub_cat_id’,’image’,’status’];

In above model class we have given statically our exact table name, which we wants to use.

Than above model class will looking like this after the updation.

class shayari extends Model
protected $table = ‘shayari ‘;
protected $fillable = [‘cat_id’,’sub_cat_id’,’image’,’status’];

As we have the shayari model.In which we can clearly see that we have mentioned the exact table name.

So laravel will not looking for a plural name of a table and it will not throw  “table does not exist error”.

Check it also

check for the documentation

How Fatal Error App\Http\Controllers\ not found


In this Fatal Error App\Http\Controllers\ not found the laravel wants to show that the model you want to use that is not available in your scope.

What does it mean thal model is not in scope for laravel ?

Laravel searching for the model class which is not included in page/controller.

So before use any model in controller you have to include  or use that  into your controller.

Note:-Above given error is very generic. It is not only for model.

it can be for session,file system ,encryption,database and many more .

So whenever this kind of error is occurred for session,database,file and so on ,than simple is that you have not included that class which you wants to use.


here wallpaper is our table name or model name, we are trying to use that in our controller but we have not included that
so  just add :-
use App\wallpaper; // or whatever your model location
into your working controller file

Check it also

check for the documentation

why laravel routes not working after server shift


“laravel routes not working properly” .

This is very common issue occured when the laravel project shifted from local host to main server.

The cause of this issue is apache configuration.It means when the project shifted, the apache requires some configuration to handling the shifting mechanism.

This is the issue of the apache2 configuration files
can be fix easily
1- go to the apache2.conf  file can be found in
2-open the above file with any editor for example :-
sudo vi /etc/apache2/apache2.conf
3- than search for below block of code
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted

and replace the above code as below code

<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
4-restart the apache2 server
sudo service apache2 restart
5-issue fix

Check it as well

Check for forum as well

Why laravel 5.2 throws internal server error

why laravel  5 throws internal server error ?

Error is coming due to insufficient file permission ,

just  gave the folder called bootstrap and storage 777 permission,

but if you put the laravel project into a sub folder on the server.

than give the whole folder 777 permission ,

your issue will be resolved

There are two ways to give permission to these two folders :-

1- From the file properties dialogue box.

2-From the command line.

But most of the time ,when permission given by the method 1 i.e from the file properties , permission some time works and some time not so the recommend ways to give the permission is by the command line :

Step to get into command line:-

Open the putty Software

Fill the host name and click on ssh than auth than upload the .ppk file for your server and click on open and you will be on the command line.

locate to your project by cd command , let say my project in /var/www/html directory, than command will be

1-cd /var/www/html

than give permission to bootstrap and storage folder

sudo chmod -R 777 storage – hit enter

sudo chmod -R 777 bootstrap- hit enter

now you done.

Check it also

check for the documentation