I am struggling with disabling view in ZF2 $this->_helper->viewRenderer->setNoRender(); or (true)
with no luck as it always says there
PHP Fatal error: Call to a member function setNoRender() on a non-object in ../module/Location/src/Location/Controller/LocationController.php on line 190
I would say just disabled the layout only
and echo your json into your view files...
You can do so using the console model, or kill execution arbitrarily.
In view use: some.phtml
json.phtml
The ZF2 is heavily under development and no guarantee can be made the way it works now, will be the way it works when ZF2 reaches a stable state.
However, the new view layer from Zend\Mvc is recently merged, which gives the option to return view models with view related information to render views. To disable view rendering, you can short-cut dispatching by returning a response directly, so the view is not rendered at all.
To disable the view completely, from within a controller action, you should return a Response object:
To disable the layout and just render this action's view model template you would do this:
$this->_helper
is not available in ZF2 but to disable a view you can do :or
Just return '' in the Method and it will not autoload the View template