我在zend框架中创建了一个插件,并在bootstrap.php中注册了这个插件。但我的页面显示错误
Class' Application_Plugin_AccessCheck'在bootstrap.php文件中找不到。
这是我在application / plugins / AccessCheck.php
中的插件文件 <?php
class Plugins_AccessCheck extends Zend_Controller_Plugin_Abstract{
public function preDispatch(){
echo "predispatched function called";
}
}
这是我的bootsrap文件
<?php
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
protected function _initAutoload()
{
$modelLoader = new Zend_Application_Module_Autoloader(array(
"namespace" => "Application",
"basePath" => APPLICATION_PATH
));
$front = Zend_Controller_Front::getInstance();
$front->registerPlugin(new Plugins_AccessCheck());
$front->dispatch();
return $modelLoader;
}
}
这是我的申请
[production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1
includePaths.library = APPLICATION_PATH "/../library"
bootstrap.path = APPLICATION_PATH "/Bootstrap.php"
bootstrap.class = "Bootstrap"
appnamespace = "Application"
resources.frontController.controllerDirectory = APPLICATION_PATH"/controllers"
resources.frontController.params.displayExceptions = 1
resources.layout.layoutPath = APPLICATION_PATH "/layouts/scripts/"
resources.db.params.adapter = "PDO_MYSQL"
resources.db.params.host ="localhost"
resources.db.params.username = "root"
resources.db.params.password = "root"
resources.db.params.dbname = "zfproject"
resources.db.params.default = true
我刚接触到zend.idont知道我的问题是什么。有人帮忙
答案 0 :(得分:0)
您使用命名空间Application
设置模块自动加载器,因此请尝试将类重命名为Application_Plugins_AccessCheck
:
class Application_Plugins_AccessCheck extends Zend_Controller_Plugin_Abstract
{
public function preDispatch()
{
echo "predispatched function called";
}
}
然后:
$front = Zend_Controller_Front::getInstance();
$front->registerPlugin(new Application_Plugins_AccessCheck());
$front->dispatch();
return $modelLoader;
答案 1 :(得分:0)
将类名更改为Application_Plugin_AccessCheck解决了问题