In fact, you do not need to access the application configuration inside the view. In MVC, views are simply responsible for displaying / rendering data (output) and should not contain any business logic or application.
If you really want to do this, you can simply pass something like this to your controller:
<?php namespace YourModule\Controller; use Zend\View\Model\ViewModel; // ... public function anyAction() { $config = $this->getServiceLocator()->get('config'); $viewModel = new ViewModel(); $viewModel->setVariables(array('config' => $config )); return $viewModel; } // ... ?>
So in your view.phtml file;
<div class="foo"> ... <?php echo $this->config; ?> ... </div>
edigu source share