How to output custom HTTP body contents with CakePHP 3.4? Echoing causes “Unable to emit headers” error
Using CakePHP 3.4, PHP 7.0. I'm attempting to do a really simple controller method to output some JSON. It is outputting "Cannot modify headers...". public function test() { $this->autoRender = false; echo json_encode(['method' => __METHOD__, 'class' => get_called_class()]); } Browser output {"method":"App\\Controller\\SomeController::test", "class":"App\\Controller\\SomeController"} Warning (512): Unable to emit headers. Headers sent in file=... Warning (2): Cannot modify header information - headers already sent by (output started at ...) Warning (2): Cannot modify header information -