Zend Framework models not loaded by autoloader

I installed my application using Zend_Application. I have a method _initAutoload()in my Bootstrap.php that looks like this:

 public function _initAutoload(){
     $this->bootstrap("frontController");
     $front = $this->frontController;

     $autoloader = Zend_Loader_Autoloader::getInstance();

     $autoloader->registerNamespace('Client_');
     $autoloader->registerNamespace('Frontend_');
     $autoloader->registerNamespace('Global_');
     $autoloader->registerNamespace('Global_Helper_');
     $autoloader->setFallbackAutoloader(true);

     $modules = $front->getControllerDirectory();
     $default = $front->getDefaultModule();

     foreach (array_keys($modules) as $module) {
         if ($module === $default) {
             continue;
         }

         $autoloader->pushAutoloader(new Zend_Application_Module_Autoloader(array(  
             "namespace" => ucwords($module),
             "basePath" => $front->getModuleDirectory($module),
         )));

     }

     return $autoloader;  
 }

I have FrontController installed so that the default module prefix is also (it seems more logical to me)$front->setParam("prefixDefaultModule", true)

I think I have the usual directory structure.

Problem:

, . (www). - . frontend , :). . . index.php, theres env. env .. env application.xml. application.xml(, api ..) , ( , .., ).

application.xml . , - ..


domain.com/client domain.com/api - . API, Client_Model_NameOfTheModel , , - /modules/client/models/NameOfTheModel.php DbTable/NameOfTheModel.php

(client.domain.com, api.domain.com ..), - . " ".

: include (Client/Model/ContactLists.php) [function.include]: : [heres-my-path-to-root]/library/Zend/Loader. php 136

: include() [function.include]: "Client/Model/ContactLists.php" (include_path = '[heres-my-path-to-root]/library:.:/usr/lib/php:/usr/local/lib/php ') [heres-my-path-to-root]/library/Zend/Loader.php 136

: Class 'Client_Model_ContactLists' [heres-my-path-to-root]/application/modules/client/controllers/ContactListsController.php 4

2 , . . , application.xml . . , , ( -).

- .
PS. .

+3
2

, , - :

 $autoloader->setFallbackAutoloader(true);

 $modules = $front->getControllerDirectory();
 $default = $front->getDefaultModule();

 foreach (array_keys($modules) as $module) {
     if ($module === $default) {
         continue;
     }

, , , , , , , . concat ?

, ,

         "namespace" => ucwords($module),

,

         "namespace" => ucwords($module) . "_",

.

+3

ZF ?

1.8 - 1.10?

, Zend_Application . , , .. .

application.ini, :

resources.modules.module_name = "enabled"

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

+1

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


All Articles