Using routes.php with Phil Sturgeon's REST_Controller |
[eluser]alexanderm[/eluser]
I have a working REST controller called api.php that extends Phil's. I don't want every line of controller logic for my whole API in my api.php. I want people to hit: www.me.com/api/<some_resource> and www.me.com/api/<some_unrelated_resource> without having all the CRUD/etc. for some_resource and some_unrelated_resource in the same file. I would end up with a file that's like 10,000 lines long. Yuck. I want the CRUD for some_resource to be self contained in a file so that I can easily copy it to create CRUD for some_other_resource. I'm trying to use routes.php, but routes don't seem to work with Phil's framework. I got routes working for non-REST_Controller extension classes, so I'm confident I'm using them correctly. What should I do?
[eluser]DJMOHNL[/eluser]
as i read it i think that you mean: you want the: domain.com/api/function to be used as: domain.com/api/A_Variable_here/Another_Variable_Here what the _remap function will do is convert: www.yourdomain.com/controller/index/variable (index can be function name if there is one that matches the in url) to www.yourdomain.com/controller/variable (it sents the 'variable' to the index function of the controller if there is no 'function' name equal variable name.) Code: // it sends the domain.com/[1st_segment]/[2nd_segment]/[3rd_segment] - remember to paste this code as the last function in your controller, as it is the last action to be handled if needed only. Then use your controller functions as: Code: // This is the index() function inside your controller you can set them to null, blank '' or a default value. You must remember, always set a null at least! you cant use index($variable,$variable2) this would give some errors on some request types. Hope it helps. |
Welcome Guest, Not a member yet? Register Sign In |