I think you might have meant to post this to the zf-contributors maillist where most ZF2 discussions are happening.

if (false === class_exists('ClassA')) { //dynamically check to see if
a local overriding class exists via the autoloader
   $class = new DefaultClass();
} else {
   $class = new ClassA();
}

What is an "overriding class"? The idea in PHP 5.3 and ZF2 is that all classes exist within some namespace. You should never have a class of the same name in the same namespace but on different places on the filesystem.

Having multiple registered spl_autoload handlers will incur
unnecessary cycles, and the developer will not have the ability of
controlling the autoloading stack (e.g circumventing it), I'm
wondering if it would be better to have one registered handler similar
to the ZF1 plugin priority stack.

If you are concerned with multiple code-bases playing nice together, you can always fore-go the Autoloader::register() method that most autoloaders have to to "auto-register" themselves, and simply pass the autoloader object to spl_autoload_register yourself.

By doing that, you can be sure that the stack of autoloaders is exactly as you expect it to be. You can also use the PHP 5.3 only feature of spl_autoload_register "prepend flag" to ensure things are in the order you expect them to be in:

http://php.net/manual/en/function.spl-autoload-register.php

-ralph

--
List: fw-general@lists.zend.com
Info: http://framework.zend.com/archives
Unsubscribe: fw-general-unsubscr...@lists.zend.com


Reply via email to