If you want to reach them using a separate URL (/api/function_name.json) then using admin routing with an ‘api’ route. Then you api methods would have an api prefix (e.g. api_index) and would be reached via /api/controller/action/variable.json.
Here’s a good article that explains it much better: http://www.dereuromark.de/2014/01/09/ajax-and-cakephp/. It’s actually about ajax, but the set up and principles are very close.
On 2 Jul 2014, at 10:49, Hatem Ben Raïs <hatem.benrais@gmail.com> wrote:
Hi,I have an app which requires some Api to expose its services. I am trying to group all the Api related controllers in a directory as explained in the doc here : http://book.cakephp.org/2.0/en/development/configuration.htmlSo :1- I created a /app/Controller/Api folder and moved the controllers in it.2- added this code to my bootstrap.php : App::build(array('Controller' => array( DS . 'app' . DS . 'Controller', DS . 'app' . DS . 'Controller' . DS . 'Api',), ));When I try to call one of the actions I get an error saying the controller cannot be found :returns{"code":404,"name":"Controller class ArticlesController could not be found.","message":"Controller class ArticlesController could not be found.","url":"\/XXXX\/api\/articles.json"}Anyone can help me figuring out what is missing please? The doc seems so clear...Thanks!--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment