Loader doesn't follow PSR-4 specification
I ran into a problem and I realized that the Loader doesn't allow a namespace to be mapped to multiple directories. Take this PSR-4 example for instance:
$loader->addNamespace('Foo\Bar', '/path/to/packages/foo-bar/src');
$loader->addNamespace('Foo\Bar', '/path/to/packages/foo-bar/tests');
This is currently not possible with Phalcon\Loader because it threats the namespaces array as unidimensional. Is this a know issue? Any plans to fix that?
Yes, we plan to fix it. Something like this:
$loader->registerNamespaces('Foo\Bar', '/path/to/packages/foo-bar/src');
$loader->registerNamespaces(
'Buz\Bar',
[
'/path/to/packages/buz-bar/src1',
'/path/to/packages/buz-bar/src2',
'/path/to/packages/buz-bar/src3'
]
);
@noobiwan I've introduced Phalcon\Loader\Extended in the Phalcon Incubator. This component extends Phalcon\Loader and adds ability to set multiple directories a namespace.
Also I have tried to implement this directly in the Phalcon. But we have some difficulties with the latest version of Zephir and Phalcon 2.1 . This will be fixed later.
However, I would like to draw your attention that even if we fix this PR or/and some Zephir issues, the ability that you described will be implemented in Phalcon 2.1, not in 2.0.x
Thank you @sergeyklay
Thank you for contributing to this issue. As it has been 90 days since the last activity, we are automatically closing the issue. This is often because the request was already solved in some way and it just wasn't updated or it's no longer applicable. If that's not the case, please feel free to either reopen this issue or open a new one. We will be more than happy to look at it again! You can read more here: https://blog.phalconphp.com/post/github-closing-old-issues