Skip to content

Commit 590a8d7

Browse files
author
Noel Garcia
committed
added a tip to register annotations namespaces
1 parent 6de738d commit 590a8d7

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

components/validator/resources.rst

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,21 @@ To disable the annotation loader after it was enabled, call
124124
In order to use the annotation loader, you should have installed the
125125
``doctrine/annotations`` and ``doctrine/cache`` packages from `Packagist`_.
126126

127+
.. tip::
128+
129+
  Remember that annotation classes aren't loaded automatically, so you should load
130+
them like Symfony usually does in the ``app/autoload.php`` file::
131+
132+
      use Composer\Autoload\ClassLoader;
133+
use Doctrine\Common\Annotations\AnnotationRegistry;
134+
135+
/** @var ClassLoader $loader */
136+
$loader = require __DIR__.'/../vendor/autoload.php';
137+
138+
AnnotationRegistry::registerLoader([$loader, 'loadClass']);
139+
140+
return $loader;
141+
127142
Using Multiple Loaders
128143
----------------------
129144

0 commit comments

Comments
 (0)