I am trying to build a web API with CodeIgniter as PHP framework.
This is not a REST api. It is just a Web api which mean all queries will be POST queries.
A typical query will look like this
http://host/api1/user/get_name
and
http://host/api2/user/get_name
Under such circumstances api1 and api2 become controllers and user becomes a method under it.
I am not happy with this because then my api1 and api2 classes become too large and also I dont like to mix unrelated code in a single class.
What can I do ? Can I play with my .htaccess file or the routing configuration such that everytime the server receives a request of the form \^api\ it forwards it to appropriate controller ?
Please note that api1 and api2 are not the only controllers in my system.
You have to consider the couple of things
If they are not interdependent then i will recommend you to do this
If they are interdependent then you must do
Reason behind that is you do not need to maintain the 2 different models.
For example, if you made some changes in a
X_model.php, you have to upload that on both server.And you can create folder under controller. I am very confirm about that. I have done it in
codeigniter 1.7.So you can create folder respectively and continue with it.!