symfony/symfony — Issue #2558: [ClassLoader] Allow to register specific namespaces/prefixes even after generic ones
Author: alessandro1997
Created: 2011-11-03 19:34:19+00:00
State: open

I think it would be great if we could write something like this:

```php
$loader->registerNamespaces(array(
// ...
'Doctrine\\Common' => __DIR__.'/../vendor/doctrine-common/lib',
'Doctrine\\Common\\DataFixtures' => __DIR__.'/../vendor/doctrine-fixtures/lib',
// ...
));
```

And have the autoloader load the ```Doctrine\Common\DataFixtures\FooClass``` from the ```doctrine-fixtures/lib``` directory even if the specific namespace comes after the generic one.

It's also easy to achieve: it would be sufficient to order the namespaces/prefixes for length when registering new ones. I can work on a patch if this interests someone else.

Let me know.