Zend Module Bootstrap无法加载 [英] Zend Module Bootstrap does not load
问题描述
在一个非常奇怪的情况下,我的模块正在工作,但是模块的boostrap没有被加载.
I have a very strange case where my Module is working but my Module's boostrap is not being loaded.
这是我的application.ini中用于模块自动加载的段:
Here is the segment in my application.ini for module autoloading:
resources.frontController.moduleDirectory = APPLICATION_PATH "/modules"
resources.modules[] = ""
这是引导程序:
protected function _initAutoload()
{
$autoloader = new Zend_Application_Module_Autoloader(array(
'namespace' => 'User_',
'basePath' => APPLICATION_PATH .'/modules/user',
'resourceTypes' => array (
'model' => array(
'path' => 'models',
'namespace' => 'Model',
)
)
));
}
我的模块的结构
Application
--modules
----user
------config/
------controllers/
------models/
------views/
------Bootstrap.php
----admin
这里的问题是没有加载User_Bootstrap.
The problem here is that User_Bootstrap is not being loaded.
<?php
class User_Bootstrap extends Zend_Application_Module_Bootstrap
{
protected function _initAutoload()
{
Zend_Registry::set('debug', 'haha');
}
}
通过在任何控制器上执行Zend_Registry :: get('debug'),它无法识别该密钥是在模块引导程序中设置的.实际上,User_Bootstrap中的任何语法错误均不起作用.
By doing a Zend_Registry::get('debug') on any controller, it doesn't recognize that the key was set in the module bootstrap. In fact any syntax error in the User_Bootstrap does not work.
我不知道为什么User_Bootstrap没有被自动加载.这让我发疯了,因为我已经研究了5个小时,甚至无法获得一篇涉及该案例的博客文章...
I don't know why User_Bootstrap is not being autoloaded. This is driving me crazy because I've been researching for 5 hours and can't even get a blog post close to covering this case...
说到这,我的模型和控制器类都可以自动加载了.
Speaking of which, my models and controller classes are being autoloaded fine.
推荐答案
尝试以下操作...
-
更改您的
application.ini
文件以使用
; lose the quotes
resources.modules[] =
从Application Bootstrap
类中删除_initAutoload()
方法.您不需要它,因为模块引导程序会自动为您的User_
类
Remove the _initAutoload()
method from your Application Bootstrap
class. You don't need this as the module bootstrap will automatically create a resource loader for your User_
classes
这篇关于Zend Module Bootstrap无法加载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!