diff --git a/_includes/_annotation_loader_tip.rst.inc b/_includes/_annotation_loader_tip.rst.inc new file mode 100644 index 00000000000..ed43b8f51d8 --- /dev/null +++ b/_includes/_annotation_loader_tip.rst.inc @@ -0,0 +1,19 @@ +.. note:: + + In order to use the annotation loader, you should have installed the + ``doctrine/annotations`` and ``doctrine/cache`` packages with Composer. + +.. tip:: + + Annotation classes aren't loaded automatically, so you must load them + using a class loader like this:: + +       use Composer\Autoload\ClassLoader; + use Doctrine\Common\Annotations\AnnotationRegistry; + + /** @var ClassLoader $loader */ + $loader = require __DIR__.'/../vendor/autoload.php'; + + AnnotationRegistry::registerLoader([$loader, 'loadClass']); + + return $loader; diff --git a/components/routing.rst b/components/routing.rst index 686faf31ccb..1b8c291fa6e 100644 --- a/components/routing.rst +++ b/components/routing.rst @@ -312,6 +312,8 @@ Last but not least there are route definitions from class annotations. The specific details are left out here. +.. include:: /_includes/_rewrite_rule_tip.rst.inc + The all-in-one Router ~~~~~~~~~~~~~~~~~~~~~ diff --git a/components/serializer.rst b/components/serializer.rst index cb16d951afc..668039f4b05 100644 --- a/components/serializer.rst +++ b/components/serializer.rst @@ -312,6 +312,8 @@ You are now able to serialize only attributes in the groups you want:: ); // $obj2 = MyObj(foo: 'foo', bar: 'bar') +.. include:: /_includes/_rewrite_rule_tip.rst.inc + .. _ignoring-attributes-when-serializing: Ignoring Attributes diff --git a/components/validator/resources.rst b/components/validator/resources.rst index 23e5ba83cde..b8e16755cda 100644 --- a/components/validator/resources.rst +++ b/components/validator/resources.rst @@ -119,10 +119,7 @@ method. It takes an optional annotation reader instance, which defaults to To disable the annotation loader after it was enabled, call :method:`Symfony\\Component\\Validator\\ValidatorBuilder::disableAnnotationMapping`. -.. note:: - - In order to use the annotation loader, you should have installed the - ``doctrine/annotations`` and ``doctrine/cache`` packages from `Packagist`_. +.. include:: /_includes/_rewrite_rule_tip.rst.inc Using Multiple Loaders ----------------------