Zend Module Bootstrap does not load

柔情痞子 提交于 2019-12-10 18:51:55

问题


I have a very strange case where my Module is working but my Module's boostrap is not being loaded.

Here is the segment in my application.ini for module autoloading:

resources.frontController.moduleDirectory = APPLICATION_PATH "/modules"
resources.modules[] = ""

Here is the bootstrapper:

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',
                )
            )
        ));
    }

Structure of my modules

Application
--modules
----user
------config/
------controllers/
------models/
------views/
------Bootstrap.php
----admin

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');
    }
}

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.

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.


回答1:


Try the following...

  1. Change your application.ini file to use

    ; lose the quotes
    resources.modules[] = 
    

    See http://framework.zend.com/manual/en/zend.application.available-resources.html#zend.application.available-resources.modules

  2. 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




回答2:


Not sure but it might as simple as improper case. --Modules is in your structure but you keep referring to it as /modules. These should match case.

I hope it's that simple.

Don't duplicate the function names of your main bootstrap in your module bootstrap, as far as I know in ZF 1.x all of the boostraps get processed every call and I think your _initAutoload in the main boostrap is overriding the module bootstrap.

try calling your function some different like _initModuleAutoload.
At least worth a shot :)




回答3:


Have you tried disabling frontController directory in application.ini config file? Try commenting/deleting this line:

resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers"



来源:https://stackoverflow.com/questions/9371615/zend-module-bootstrap-does-not-load

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!