I’m trying to learn about JSON routes, so I whipped up a fresh “bookmarker tutorial” app and tried adding the option for using a /bookmarks.json URL. But I’m getting an error message saying that the
Template file “Bookmarks/json/index.ctp” is missing.
Here’s what I tried: I installed a new version of the bookmarker tutorial from the cakePHP site; baked the scaffolded, hash-protected the passwords; added a user; added a few bookmarks. Then I tried two different approaches to adding a json option to the ‘config/routes.php’ file:
Router::extensions(['json','xml']);
and then when that didn’t work, I tried
Router::scope('/', function (RouteBuilder $routes) {
$routes->setExtensions(['json','xml']);
...
instead.
(Those methods are both mentioned in : https://book.cakephp.org/3.0/en/development/routing.html#routing-file-extensions )
I confirmed that I have a call to the RequestHandler in my AppController.php file.
$this->loadComponent('RequestHandler');
You can see a git repo of these developments at: https://github.com/kenirwin/cake-json/commits/routes
Any idea what I’m doing wrong?
(This, of course, it not what I’m trying to work on. This was supposed to be the easy setup so I could start learning about making it more complex…)
Thanks
Ken