0

我想将变量发送到 zend 框架中的布局,我尝试为其创建一个控制器插件并将其放置在

application
    /plugins

并将文件命名为layout.php,这是来自的代码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';
   }
}

现在我想用application.ini我尝试添加的frontController注册插件

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

它向我显示以下错误。

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

我是zend框架的新手。我哪里错了?

4

2 回答 2

2

添加你的application.ini

pluginPaths.Plugins = APPLICATION_PATH "/Plugins"

重命名resources.frontController.plugins[] = "Plugin_Layout"为,resources.frontController.plugins.Layout = "Plugin_Layout"frontController.plugins[]无论如何都应该工作。

并将您的插件文件夹重命名为Plugins并将您的layout.php文件重命名为Layout.php,这应该可以工作。

于 2012-04-07T15:36:56.567 回答
1

你的路径应该是

includePaths.plugin = APPLICATION_PATH "/Plugins"

注意大写P。

于 2012-04-07T14:47:47.970 回答