简体   繁体   中英

registering controller plugins with front controller in zend framework

i wanted to send variables to the layout in zend framework for which i tried creating a controller plugin and placed it in

application
    /plugins

and named the file as layout.php , here is the code from layout.php

class Plugin_Layout extends Zend_Controller_Plugin_Abstract
{
   public function preDispatch(Zend_Controller_Request_Abstract $request)
   {
      $layout = Zend_Layout::getMvcInstance();
      $view = $layout->getView();
      $view->foo = 'bar';
   }
}

now i wanted to register the plugin with the frontController in application.ini for which i tried adding

includePaths.plugin = APPLICATION_PATH "/plugins"
autoloaderNamespaces[] = "Plugin_"
resources.frontController.plugins[] = "Plugin_Layout"

it shows me following error.

Warning: include_once(Plugin/Layout.php) [function.include-once]: failed to open stream: No such file or directory in /Users/azhararmar/htdocs/joofris/library/Zend/Loader.php on line 146

i am new to zend framework. where am i going wrong?

Add in your application.ini :

pluginPaths.Plugins = APPLICATION_PATH "/Plugins"

Rename resources.frontController.plugins[] = "Plugin_Layout" to resources.frontController.plugins.Layout = "Plugin_Layout" but frontController.plugins[] should work anyway.

and rename your plugin folder to Plugins and your layout.php file to Layout.php , this should work.

Your path should be

includePaths.plugin = APPLICATION_PATH "/Plugins"

Note the capital P.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM