Search code examples
phpcodeignitermobile-application

How best to integrate mobile services with CodeIgniter?


I have a website that I built on the CodeIgniter framework. It implements the MVC architecture.

My dilemma is: I am developing applications for mobiles. A little research told me that mobile apps cannot connect directly to MySQL databases and thus, I need to have a service layer in between - in my case, they will be PHP scripts.

Is it possible (and should I) for me to integrate these scripts into my MVC architecture. If yes, how should I go about it?

Currently, I have this in mind:

  • Mobile app makes POST request to a controller
  • Controller gets data from the db via the Model
  • Controller encodes data in JSON and sends back to mobile app

Would that be the correct way to implement it?

This is my first time implementing something like this so I want to make sure I'm not missing something.


Solution

  • Better yet, create a full REST server for your mobile app to use. You can get an idea of how easy it is with this tutorial:

    http://net.tutsplus.com/tutorials/php/working-with-restful-services-in-codeigniter-2/

    This will have a link to the library as well,