cphalcon icon indicating copy to clipboard operation
cphalcon copied to clipboard

Loader doesn't follow PSR-4 specification

Open luiz-brandao opened this issue 11 years ago • 4 comments

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?

luiz-brandao avatar Oct 14 '15 16:10 luiz-brandao

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'
    ]
);

sergeyklay avatar Oct 14 '15 19:10 sergeyklay

@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

sergeyklay avatar Oct 24 '15 10:10 sergeyklay

Thank you @sergeyklay

borisdelev avatar Oct 27 '15 21:10 borisdelev

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

stale[bot] avatar Apr 17 '18 03:04 stale[bot]