Change the default module of Zend Framework

I am working on a project and have the following project layout:

|Project |-Application |-api |-configs |-controllers |-models |-modules |-core |-controllers |-models |-views |-Bootstrap.php |-site1 |-site2 |-site3 |-views |-Bootstrap.php |-Docs |-Library |-Public |-.zfproject.xml 

I used this in my application.ini application to install the default module as the core module:

 resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers" resources.frontController.moduleDirectory = APPLICATION_PATH "/modules" resources.frontController.defaultModule = "core" resources.frontController.defaultControllerName = "Index" resources.frontController.defaultAction = "index" resources.modules[] = "" 

My problem is that for some reason I cannot get boot files working in modules. It is almost as if the module is not changing by default. The application behaves as it is until I try to load the boot files - I get this error:

Fatal error: uncaught exception 'Zend_Application_Resource_Exception' with the message 'Boot file found for module' default 'but boot class' Default_Bootstrap not found' in M: \ Zend_Framework \ library \ Zend \ Application \ Resource \ Modules.php on line 85

The prefix for this error is:

Zend_Application_Resource_Exception: Bootstrap file found for module "default" but bootstrap class "Default_Bootstrap" was not found in M: \ Zend_Framework \ library \ Zend \ Application \ Resource \ Modules.php on line 85

Can anyone see where I'm wrong?

My application file /Bootstrap.php:

 class Bootstrap extends Zend_Application_Bootstrap_Bootstrap { } 

My Application / Core / Bootstrap.php file:

 class Core_Bootstrap extends Zend_Application_Module_Bootstrap { } 
+4
source share
2 answers

Not 100%, but if you delete the following line:

 resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers" 

which can solve the problem. If I am not mistaken, since you are using modules, installing this will result in an error.

+6
source

It looks like you might be missing one line from your application.

 resources.frontController.params.prefixDefaultModule = "" 

Try using it this way and see if it works, I think this just tells the application that when using the modules, the module named "default" has no prefix.
Although I may be wrong, so you may have to experiment. Well, maybe two lines are missing :)

 resources.frontController.moduleControllerDirectoryName = "controllers" 
0
source

Source: https://habr.com/ru/post/1393369/


All Articles