Gabe
Gabe

Reputation: 83

Zend Autoloader: custom library in Module-Folder

Why ist the Zend_Autoloader not able to load my Classes. Tha path to the library should be: /root/application/modules/modulexy/MyLib (Zend Version 1.12)

What i did:

  1. In the public/index.php

set_include_path(implode(PATH_SEPARATOR, array( ... realpath(APPLICATION_PATH . '/modules/modulexy/MyLib'), ... )));

  1. In the Controller

    $al = Zend_Loader_Autoloader::getInstance(); $al->registerNamespace("MyLib_");

I don't want to move the library to /root/library

Upvotes: 2

Views: 300

Answers (1)

sorohan
sorohan

Reputation: 856

Your include path shouldn't include the "MyLib" part.

This should work:

set_include_path(implode(PATH_SEPARATOR, array(
      ...
      realpath(APPLICATION_PATH . '/modules/modulexy'),
      ...
      )));

Alternatively, if you want that lib extra directory, you could have

set_include_path(implode(PATH_SEPARATOR, array(
      ...
      realpath(APPLICATION_PATH . '/modules/modulexy/lib'),
      ...
      )));

And place your class "MyLib_Model_Abstract" in "/modules/modulexy/lib/MyLib/Model/Abstract.php

Upvotes: 2

Related Questions