• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
RESTful server with CI


I am going to be using Dojo's widgets enabled with what's called RESTful store
(that is all Dojo's widgets such as trees/grids/combo boxes)

will invoke internally communication methods to get the data from the server automatically

For that to work, my server needs to be a 'RESTful' server


so I wanted to know if there are CI helpers libraries that will make it easy for me to
create skeleton methods at least for RESTFUL stuff

thank you in advance

[eluser]Phil Sturgeon[/eluser]
I have been working on a REST implementation for CodeIgniter recently. It all works fine other than setting cache in config and digest having a few troubles for browser viewing. Those will both be non-issues for most users.

Take a look at the default controller and the example controller for help on this.

Sadly if you Google "rest codeigniter" I am the 5th entry, but if you clicked on the first CodeIgniter Forums link it displayed you would have found me anyway. :-)

hi, thank you very much

I am trying it now.

the rest.php config file appears not to be linked correctly from you site, so I went directly to github to get it.

also your example says user/435 but index 435 is not defined so I just changed to 1 or 2 or 3.

other than the above the example started working so I am learning it.

If you have any suggestions/pointers on integration with things like dojo -- please let me know

have a question:

I do not quite understand the logic behind naming the controller and naming methods within the controller

basically I need a RESTful implementation for Orders table

so do I name the controller Orders

or do I name methods


in your web page Controller name appears to be unrelated to the resource name
and then you use 'users' and 'user' in different places so I am not sure

thanks in advance

[eluser]Phil Sturgeon[/eluser]
If you have a site that mixes standard web output with an API in there too, you will want to call your controller something like api.php or order_api.php. If you are REST only then call it orders.php

Then your REST calls could be:


This would match up to:

function order_get()
    $id = $this->get('id');

You dont need to use put unless you plan on using cURL to add new orders. Most wont need to do this and you can always use POST to achieve the same result which works from the browser too.

In my example, users_get means get multiple users. user_post means get a single user and user_post means update a single user.

Notice the use of plural and singular to give different meaning, combined with the HTTP Request Method to show what we are doing with it.

You can name a call /orders/do_something_totally_mental/something/df453 if you like, it really doesn't matter as long as your method is "function do_something_totally_mental_get()".

[eluser]Phil Sturgeon[/eluser]
Did you get the hang of this in the end?

I really need to make some user documentation...

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.