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


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:

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

in getClassPath().


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).

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.

I have submitted the patch here