I have my own lib at folder “classes”. I am trying to use Zend library as standalone. (Integrating their classes into my app).
E.g. as below. Zend classes all put under a folder called Zend
classes/db.class.php
classes/Zend/translate.php ….
I use an autoload function to load classes previously.
if (!function_exists ("__autoload")){
function __autoload($class_name)
{
if(file_exists(ABSPATH.'/classes/'.$class_name.'.class.php')){
require_once ABSPATH.'/classes/'.$class_name.'.class.php';
}
}
}
My function check if my app require my class, if so, i will load it from my “classes” folder if not it will load from Zend folder.
Whenever i call
require_once ABSPATH.'/classes/Zend/Loader/Autoloader.php';
$loader = Zend_Loader_Autoloader::getInstance();
It keep saying that my “own” classes are not loaded. I think this is an issue with Zend auto load, it check and find out that it need db.class.php in the zend folder.
How do i do this as i went to separate libraries between Zend and my Own.
The magic
__autoloadfunction does not support multiple autoloaders. If you specify your custom autoloader as shown above and then register a Zend autoloader, the previously installed autoloader will be overwritten by the Zend autoloader.Since the Zend component uses spl_autoload_register(), you may also use this method (multiple autoloaders are supported – it basically installs a single autoloader that processes another stack of (user-defined) autoloaders).
http://php.net/manual/function.spl-autoload-register.php