title: How to output custom HTTP body contents with CakePHP 3.4? Echoing causes "Unable to emit headers" error
body: <p>Using CakePHP 3.4, PHP 7.0.</p>
  
  <p>I'm attempting to do a really simple controller method to output some JSON. It is outputting "Cannot modify headers...".</p>
  
  <pre><code>public function test() {
      $this-&gt;autoRender = false;
      echo json_encode(['method' =&gt; __METHOD__, 'class' =&gt; get_called_class()]);
  }
  </code></pre>
  
  <p>Browser output</p>
  
  <pre><code>{"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 - headers already sent by (output started at ...)
  </code></pre>
  
  <p>I fully understand why PHP complains about this.  The question is why does CakePHP complain and what can I do about it?</p>
  
  <p>It should be noted that CakePHP 2.x allowed this.</p>