zf2 disable the view completely disable the layout within controller change view

To disable the view completely, from within a controller action, you should return a Response object:
 

< ?php
namespace SomeModule\Controller;
use Zend\Mvc\Controller\ActionController,
    Zend\View\Model\ViewModel;

class SomeController extends ActionController
{
    public function someAction()
    {
        $response = $this->getResponse();
        $response->setStatusCode(200);
        $response->setContent("Hello World");
        return $response;
    }   
}

disable the layout within controller
 


    $result = new ViewModel();
    $result->setTerminal(true);
    return $result;

change view

function someAction()
{
    $result = new ViewModel();
    $result->setTemplate('somemodule/somecontroller/arbitraryscript');
}