So my suggestion is to
1. register your autoloader first, but modify it to return early if the class is not 5.3-namespaced
2. change Zend_Loader_Autoloader's default autoloader to yours (via setDefaultAutoloader()), but modify it to replace underscores with slashes too
3. use Zend_Loader_Autoloader::pushAutoloader($callback, $namespace) rather than registerNamespace()
-- Mon
On Sun, Jun 7, 2009 at 11:21 AM, Abraham Block <atblock@gmail.com> wrote:
I had been including my own autoloader for PHP 5.3 style classes (my understanding is that somebody is going to be adding this to PHP 5.3 itself at some point), and now after I updated my svn:externals for ZF (rev 15923), my app stopped working. It seems that when I call Zend_Loader_Autoloader::registerNamespace, this autoloader wants to take over all the other autoloaders or something like that...
Allow me to demonstrate.
This code works:
require_once 'Zend/Loader/Autoloader.php';
$autoloader = Zend_Loader_Autoloader::getInstance();
function autoload($class) {
$class = str_replace('\\', '/', $class);
include $class . '.php';
}
spl_autoload_register('autoload');
$a = new Zend_Acl;
$b = new My\Class;
but if I add $autoloader->registerNamespace('AB');
all of a sudden my autoload function is ignored!
没有评论:
发表评论