Thank you Jeremy, I'll give it a try the way it is explained in the article.
But more generally, do you have any idea why this subdirectory structure is not working? I did exactly what is mentioned in the doc. On Wednesday, July 2, 2014 11:10:18 AM UTC+1, Jeremy Burns wrote: > > It’s simpler than that. Each controller function can act as an API method, > so leave the folder structure as it is.You can detect the json extension by > using the RequestHandler component and > adding Router::setExtensions(array('json')); near the bottom of routes.php. > Then you can call /controller/action/variable.json and it’ll be handled as > json - et voila you have an api. > > 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....@gmail.com <javascript:>> > 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.html > > So : > 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 : > > *http://localhost:8888/XXXXX/api/articles.json > <http://localhost:8888/XXXXX/api/articles.json>* > > 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+u...@googlegroups.com <javascript:>. > To post to this group, send email to cake...@googlegroups.com > <javascript:>. > Visit this group at http://groups.google.com/group/cake-php. > For more options, visit https://groups.google.com/d/optout. > > > -- 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+unsubscr...@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.