Created
July 1, 2011 21:55
-
-
Save beberlei/1059486 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use Symfony\Component\ClassLoader\UniversalClassLoader; | |
$loader = new UniversalClassLoader(); | |
$loader->registerNamespaces(array( | |
'Symfony' => array(__DIR__.'/../vendor/symfony/src', __DIR__.'/../vendor/bundles'), | |
'Sensio' => __DIR__.'/../vendor/bundles', | |
'JMS' => __DIR__.'/../vendor/bundles', | |
)); | |
$loader->register(); | |
// this is a global dependency, but given the importance of autoloading in Annotations we just | |
// replaced one global dependency with another to get more control over the autoloading. | |
\Doctrine\Common\Annotations\AnnotationRegistry::registerNamespaces($loader->getNamespaces()); | |
// For Doctrine ORM it can register its annotations with | |
\Doctrine\Common\Annotations\AnnotationRegistry::registerFile("path/to/DoctrineAnnotations.php"); | |
// For any library it can register annotations with: | |
\Doctrine\Common\Annotations\AnnotationRegistry::registerNamespace("MyLibrary/Annotations", "/path/to/mylibrary-root"); |
its loaded by the universal class loader. Its just not included in the configuration here.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How the \Doctrine\Common\Annotations\AnnotationRegistry itself would be autoloaded in this example?