Skip to content

added a tip to register annotations namespaces #7511

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions _includes/_annotation_loader_tip.rst.inc
Original file line number Diff line number Diff line change
@@ -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;
2 changes: 2 additions & 0 deletions components/routing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
~~~~~~~~~~~~~~~~~~~~~

Expand Down
2 changes: 2 additions & 0 deletions components/serializer.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 1 addition & 4 deletions components/validator/resources.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
----------------------
Expand Down