ZF issue reporting?
Posted: Thu Nov 12, 2009 6:08 pm
I'm using the Zend_Mail component in my own framework and I encountered anissue with autoloaders (I actually had a similar problem with SwiftMailer and switched to Zend when I grew tired of wrestling with Swift). The problem is, I do not want to use Zend autoloader (incase I have similar issue to SwiftMailer) so I basically manually included dependencies, which for a simple mailer, is not a HUGE deal. Zend however assumes it`s the only library in use and that every file is relative to it`s own include_path base, in thie case a folder named `Zend`
Zend is buried about 3 directories deep in my LIBS directory which is not the base directory, so wheneve I include a Zend class and it has dependencies, most classes will explicitly include them with a include_once or require_once -- UGH!
Why this introduces a problem for me is two fold:
1. Whenever I include a Zend component I must now set the chdir() to the `Zend` directory first and restore when complete or whenever I need to work on files as well -- which thankfully is rare but this is still a PITA.
2. The class Zend_Mail_Transport_Smtp uses a method like class_exists to determine whether any dependencies need be included. However class_exists has an optional parameter which invokes autoload and it`s TRUE by default but looking at the code, it`s obvious this parameter should be set to false as the inclusion of dependencies is explicitly done immediately after.
Lines 190-193
Shouldnèt this be:
Adding this second parameter fixed the issue of errors in my application because now the autoload() is not invoked -- which is conflicting with my own autoloaders() I assume -- because I have not used Zends and my own have no idea how to load Zend classes -- despite following an identical convention.
Anyway, if this is not a credibe fix what would be the better solution. I assume it would be to implement a autoloader for Zend which introduces more problems, due to the fact my autoloaders will fail if they are ever invoked to handle a Zend_ class and visa-versa.
While the naming convention is identical, I have libraries stored in different base directories so I need a custom autoload to basically check the class prefix and set the base path. This works for my internal libraries but not for Zend, because Zend explicitly includes their dependencies using require_once, etc, so whenever the library is used it assumes everything is relative to it -- which is not the case unfortunately.
Suggestions, opinions, etc?
Cheers,
Alex
Zend is buried about 3 directories deep in my LIBS directory which is not the base directory, so wheneve I include a Zend class and it has dependencies, most classes will explicitly include them with a include_once or require_once -- UGH!
Why this introduces a problem for me is two fold:
1. Whenever I include a Zend component I must now set the chdir() to the `Zend` directory first and restore when complete or whenever I need to work on files as well -- which thankfully is rare but this is still a PITA.
2. The class Zend_Mail_Transport_Smtp uses a method like class_exists to determine whether any dependencies need be included. However class_exists has an optional parameter which invokes autoload and it`s TRUE by default but looking at the code, it`s obvious this parameter should be set to false as the inclusion of dependencies is explicitly done immediately after.
Lines 190-193
Code: Select all
if (!class_exists($connectionClass)) {
require_once 'Zend/Loader.php';
Zend_Loader::loadClass($connectionClass);
}Code: Select all
if (!class_exists($connectionClass, false)) {
require_once 'Zend/Loader.php';
Zend_Loader::loadClass($connectionClass);
}Anyway, if this is not a credibe fix what would be the better solution. I assume it would be to implement a autoloader for Zend which introduces more problems, due to the fact my autoloaders will fail if they are ever invoked to handle a Zend_ class and visa-versa.
While the naming convention is identical, I have libraries stored in different base directories so I need a custom autoload to basically check the class prefix and set the base path. This works for my internal libraries but not for Zend, because Zend explicitly includes their dependencies using require_once, etc, so whenever the library is used it assumes everything is relative to it -- which is not the case unfortunately.
Suggestions, opinions, etc?
Cheers,
Alex