Skip to content

Commit 84c1541

Browse files
author
Noel Garcia
committed
added a tip to register annotations namespaces
1 parent 861e72b commit 84c1541

File tree

3 files changed

+55
-0
lines changed

3 files changed

+55
-0
lines changed

components/routing.rst

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,26 @@ Last but not least there are
312312
route definitions from class annotations. The specific details are left
313313
out here.
314314

315+
.. note::
316+
317+
In order to use the annotation loader, you should have installed the
318+
``doctrine/annotations`` and ``doctrine/cache`` packages from `Packagist`_.
319+
320+
.. tip::
321+
322+
  Remember that annotation classes aren't loaded automatically, so you should load
323+
them like Symfony usually does in the ``app/autoload.php`` file::
324+
325+
      use Composer\Autoload\ClassLoader;
326+
use Doctrine\Common\Annotations\AnnotationRegistry;
327+
328+
/** @var ClassLoader $loader */
329+
$loader = require __DIR__.'/../vendor/autoload.php';
330+
331+
AnnotationRegistry::registerLoader([$loader, 'loadClass']);
332+
333+
return $loader;
334+
315335
The all-in-one Router
316336
~~~~~~~~~~~~~~~~~~~~~
317337

components/serializer.rst

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,26 @@ You are now able to serialize only attributes in the groups you want::
314314

315315
.. _ignoring-attributes-when-serializing:
316316

317+
.. note::
318+
319+
In order to use the annotation loader, you should have installed the
320+
``doctrine/annotations`` and ``doctrine/cache`` packages from `Packagist`_.
321+
322+
.. tip::
323+
324+
  Remember that annotation classes aren't loaded automatically, so you should load
325+
them like Symfony usually does in the ``app/autoload.php`` file::
326+
327+
      use Composer\Autoload\ClassLoader;
328+
use Doctrine\Common\Annotations\AnnotationRegistry;
329+
330+
/** @var ClassLoader $loader */
331+
$loader = require __DIR__.'/../vendor/autoload.php';
332+
333+
AnnotationRegistry::registerLoader([$loader, 'loadClass']);
334+
335+
return $loader;
336+
317337
Ignoring Attributes
318338
-------------------
319339

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)