$this->_helper->layout()->disableLayout();
Of course in ZF2 this method doesn't work but there are some other ways how it is possible to do:
1. Set viewModel as standalone model in controller action:
public function someAction() { $viewModel = new ViewModel(array( 'foo' => 'bar' )); $viewModel->setTerminal(true); return $viewModel; }
2. Create empty layout and use it in controller action:
Create almost empty layout: module/MyModule/view/layout/empty.phtml with only content:
<?php echo $this->content; ?>
Then use this layout in controller action:
$this->layout('layout/empty');
3. Use response object for output content:
$response = $this->getResponse(); $response->setContent("Some content"); return $response;
That's all. May be there are some other ways to do this. As for me I prefer the first way, it looks simple and clean.