CakePHP 3 Tutorial 22: Serving JSON Data

Submitted by naidim on Sun, 05/21/2017 - 09:09

Serving JSON (JavaScript Object Notation) from CakePHP 3 is somewhat straight-forward, but there can be a few "gotchas" so I've written this tutorial to help others and as a reminder to myself. With the goal of presenting your CakePHP data as JSON data, here are the steps you need to follow. According to the CakePHP book ( https://book.cakephp.org/3.0/en/views/json-and-xml-views.html ) data views requires the RequestHandler component.