Skip to content

Commit 0380429

Browse files
[Documentation] Deprecate annotations
1 parent db49e10 commit 0380429

22 files changed

+89
-119
lines changed

best_practices.rst

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -207,9 +207,6 @@ Doctrine supports several metadata formats, but it's recommended to use PHP
207207
attributes because they are by far the most convenient and agile way of setting
208208
up and looking for mapping information.
209209

210-
If your PHP version doesn't support attributes yet, use annotations, which is
211-
similar but requires installing some extra dependencies in your project.
212-
213210
Controllers
214211
-----------
215212

@@ -226,12 +223,12 @@ controllers shouldn't contain any business logic. Controllers should contain
226223
nothing more than a few lines of *glue-code*, so you are not coupling the
227224
important parts of your application.
228225

229-
.. _best-practice-controller-annotations:
226+
.. _best-practice-controller-attributes:
230227

231-
Use Attributes or Annotations to Configure Routing, Caching, and Security
232-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
228+
Use Attributes to Configure Routing, Caching, and Security
229+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
233230

234-
Using attributes or annotations for routing, caching, and security simplifies
231+
Using attributes for routing, caching, and security simplifies
235232
configuration. You don't need to browse several files created with different
236233
formats (YAML, XML, PHP): all the configuration is just where you require it,
237234
and it only uses one format.

bundles/best_practices.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,8 @@ Event Listeners ``src/EventListener/``
123123
Configuration (routes, services, etc.) ``config/``
124124
Web Assets (CSS, JS, images) ``public/``
125125
Translation files ``translations/``
126-
Validation (when not using annotations) ``config/validation/``
127-
Serialization (when not using annotations) ``config/serialization/``
126+
Validation (when not using attributes) ``config/validation/``
127+
Serialization (when not using attributes) ``config/serialization/``
128128
Templates ``templates/``
129129
Unit and Functional Tests ``tests/``
130130
=================================================== ========================================
@@ -163,7 +163,7 @@ If the bundle includes Doctrine ORM entities and/or ODM documents, it's
163163
recommended to define their mapping using XML files stored in
164164
``config/doctrine/``. This allows to override that mapping using the
165165
:doc:`standard Symfony mechanism to override bundle parts </bundles/override>`.
166-
This is not possible when using annotations/attributes to define the mapping.
166+
This is not possible when using attributes to define the mapping.
167167

168168
Tests
169169
-----

components/config/resources.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ an array containing all matches.
3030
Resource Loaders
3131
----------------
3232

33-
For each type of resource (YAML, XML, annotation, etc.) a loader must be
33+
For each type of resource (YAML, XML, attributes, etc.) a loader must be
3434
defined. Each loader should implement
3535
:class:`Symfony\\Component\\Config\\Loader\\LoaderInterface` or extend the
3636
abstract :class:`Symfony\\Component\\Config\\Loader\\FileLoader` class,

components/serializer.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ for each format:
288288

289289
$classMetadataFactory = new ClassMetadataFactory(new XmlFileLoader('/path/to/your/definition.xml'));
290290

291-
.. _component-serializer-attributes-groups-annotations:
291+
.. _component-serializer-attributes-groups-attributes:
292292

293293
Then, create your groups definition:
294294

@@ -436,8 +436,8 @@ Ignoring Attributes
436436
All attributes are included by default when serializing objects. There are two
437437
options to ignore some of those attributes.
438438

439-
Option 1: Using ``@Ignore`` Annotation
440-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
439+
Option 1: Using ``#[Ignore]`` Attribute
440+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
441441

442442
.. configuration-block::
443443

components/validator/resources.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,10 @@ If you use annotations instead of attributes, it's also required to call
114114
->addDefaultDoctrineAnnotationReader() // add this only when using annotations
115115
->getValidator();
116116

117+
.. deprecated:: 6.4
118+
119+
Annotations are deprecated since Symfony 6.4, use attributes instead.
120+
117121
To disable the annotation loader after it was enabled, call
118122
:method:`Symfony\\Component\\Validator\\ValidatorBuilder::disableAnnotationMapping`.
119123

configuration/micro_kernel_trait.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ Before continuing, run this command to add support for the new dependencies:
302302

303303
.. code-block:: terminal
304304
305-
$ composer require symfony/yaml symfony/twig-bundle symfony/web-profiler-bundle doctrine/annotations
305+
$ composer require symfony/yaml symfony/twig-bundle symfony/web-profiler-bundle
306306
307307
Next, create a new extension class that defines your app configuration and
308308
add a service conditionally based on the ``foo`` value::
@@ -377,7 +377,7 @@ because the configuration started to get bigger:
377377
;
378378
};
379379
380-
This also loads annotation routes from an ``src/Controller/`` directory, which
380+
This also loads attribute routes from an ``src/Controller/`` directory, which
381381
has one file in it::
382382

383383
// src/Controller/MicroController.php

configuration/multiple_kernels.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ resources::
205205
}
206206

207207
if (false !== ($fileName = (new \ReflectionObject($this))->getFileName())) {
208-
$routes->import($fileName, 'annotation');
208+
$routes->import($fileName, 'attribute');
209209
}
210210
}
211211
}

controller.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ Mapping a URL to a Controller
6363

6464
In order to *view* the result of this controller, you need to map a URL to it via
6565
a route. This was done above with the ``#[Route('/lucky/number/{max}')]``
66-
:ref:`route attribute <annotation-routes>`.
66+
:ref:`route attribute <attribute-routes>`.
6767

6868
To see your page, go to this URL in your browser: http://localhost:8000/lucky/number/100
6969

controller/upload_file.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ so Symfony doesn't try to get/set its value from the related entity::
7272
// every time you edit the Product details
7373
'required' => false,
7474

75-
// unmapped fields can't define their validation using annotations
75+
// unmapped fields can't define their validation using attributes
7676
// in the associated entity, so you can use the PHP constraint classes
7777
'constraints' => [
7878
new File([

doctrine.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ add/remove fields, add/remove methods or update configuration.
193193

194194
Doctrine supports a wide variety of field types, each with their own options.
195195
To see a full list, check out `Doctrine's Mapping Types documentation`_.
196-
If you want to use XML instead of annotations, add ``type: xml`` and
196+
If you want to use XML instead of attributes, add ``type: xml`` and
197197
``dir: '%kernel.project_dir%/config/doctrine'`` to the entity mappings in your
198198
``config/packages/doctrine.yaml`` file.
199199

@@ -746,7 +746,7 @@ the default convention.
746746
MapEntity Options
747747
~~~~~~~~~~~~~~~~~
748748

749-
A number of options are available on the ``MapEntity`` annotation to
749+
A number of options are available on the ``MapEntity`` attribute to
750750
control behavior:
751751

752752
``id``

0 commit comments

Comments
 (0)