Problem with plugin in zend framework
I have created one plugin that is reside in application/controllers/plugin/view.php and below is its content
class Application_Controller_Plugin_View extends Zend_Controller_Plugin_Abstract { public function dispatchLoopStartup(Zend_Controller_Request_Abstract $request) { $frontController = Zend_Controller_Front::getInstance(); $view = $frontController->getParam('bootstrap')->getResource('view'); echo 'erace'; exit; $view->doctype('XHTML1_STRICT'); $baseUrl = $request->getBaseUrl(); if (defined('RUNNING_FROM_ROOT')) { $baseUrl .= '/public'; $frontController->setBaseUrl($baseUrl); } /* $view->headLink()->appendStylesheet($baseUrl . '/css/main.css'); $view->headLink()->appendStylesheet($baseUrl . '/css/screen.css', 'screen'); $view->headLink()->appendStylesheet($baseUrl . '/css/print.css', 'print');*/ } }
Then I have registered this plugin in bootstrap as follow :
protected function _i开发者_如何学编程nitLayoutHelper() { $front = Zend_Controller_Front::getInstance(); $front->registerPlugin(new Application_Controller_Plugin_View()); }
but its give me an error like
( ! ) Fatal error: Class 'Application_Controller_Plugin_View' not found in C:\wamp\www\saet_new\application\Bootstrap.php on line 42
Please help me.
Is the plugin here:
library/application/controller/plugin/view.php
?
Custom code belongs in the library folder in my opinion, and that path is already defined in index.php
I register my namespaces in the bootstrap as follows:
$autoLoader = Zend_Loader_Autoloader::getInstance();
$autoLoader->registerNamespace('Custom_');
Then library code can be put in the folder library/custom
I think it's caused because you are calling Default_Application_Controller_Plugin_View
and you're plugin is Application_Controller_Plugin_View
.
Are you using modules at all? that would explain why the Default_ would be there, although I believe the prefix isn't required unlesss prefixDefaultModule
is set.
精彩评论