ZF-8529: Namespace Package_Subpackage not supported by module Resource Loader

Issue Type: Bug Created: 2009-12-12T00:38:01.000+0000 Last Updated: 2011-03-03T23:10:12.000+0000 Status: Open Fix version(s): Reporter: Benjamin Eberlei (beberlei) Assignee: Matthew Weier O'Phinney (matthew) Tags: - Zend_Loader

Related issues: Attachments:


The module namespace loader only checks if the first segment of the given class matches the resource loaders namespace, however you could have namespaces of the type "Foo_Bar", a simple fix for this is:

<pre class="highlight">
        if (!empty($namespaceTopLevel)) {
            if (strpos($class, $namespaceTopLevel) !== 0) {
                // wrong prefix? we're done
                return false;

in getClassPath().


Posted by Steven Rosato (ratius) on 2010-09-18T11:49:35.000+0000

The fix works very well for me. I used this fix as an adhoc implementation of the zf2 ResourceAutoloader in my library and it works with PHP namespaces too (e.g Foo\Bar as a resource namespace).

Posted by Steven Rosato (ratius) on 2010-09-19T20:27:29.000+0000

I saw that this causes issues where multiple ResourceLoader objects added to the autoloader stack will not behave correctly. This is due to the autoloader class breaking on the first matching namespace when getting namespaced autoloaders. I have applied a small fix to resolve this issue to fully support subpackages. I will provide patches containing the required fix and unit tests shortly.

Posted by Steven Rosato (ratius) on 2011-03-03T23:10:09.000+0000

I have submitted the patch here

Have you found an issue?

See the Overview section for more details.


© 2006-2018 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.