title: Zend 2 variable from controller to layout.html
body: <p>I am new Zend 2. I succeed to pass data to my viewmodel, but now I want to pass a var to my layout.phtml</p>
  
  <p>How can i do that?</p>
  
  <p>controller:</p>
  
  <pre><code>&lt;?php
  
  namespace Pages\Controller;
  
  use Zend\Mvc\Controller\AbstractActionController;
  use Zend\View\Model\ViewModel;
  
  class IndexController extends AbstractActionController {
  
      function indexAction() {
          $this-&gt;layout()-&gt;myVariable = array('bas'=&gt;'man');
          return new ViewModel(array(
              'data' =&gt; 'home'
          ));      
  }
  </code></pre>
  
  <p>}</p>
  
  <p>layout.phtml:</p>
  
  <pre><code>print_r($this-&gt;layout()-&gt;myVariable);
  </code></pre>