Skip to content

Instantly share code, notes, and snippets.

@uedatakeshi
Created January 31, 2015 07:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save uedatakeshi/4856c087d105b25cc0f4 to your computer and use it in GitHub Desktop.
Save uedatakeshi/4856c087d105b25cc0f4 to your computer and use it in GitHub Desktop.
CakePHP3 Json output
public function initialize()
{
parent::initialize();
$this->loadComponent('RequestHandler');
}
public function api()
{
$this->viewClass = 'Json';
$this->set('articles', $this->Articles->find());
$this->set('_serialize', ['articles']);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment