Skip to content

Commit 14d8b13

Browse files
[Documentation] Deprecate annotations
1 parent db49e10 commit 14d8b13

23 files changed

+73
-83
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: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,10 @@ Now it looks like this::
298298
}
299299
}
300300

301+
.. deprecated:: 6.4
302+
303+
Annotations are deprecated since Symfony 6.4, use attributes instead.
304+
301305
Before continuing, run this command to add support for the new dependencies:
302306

303307
.. code-block:: terminal
@@ -377,7 +381,7 @@ because the configuration started to get bigger:
377381
;
378382
};
379383
380-
This also loads annotation routes from an ``src/Controller/`` directory, which
384+
This also loads attribute routes from an ``src/Controller/`` directory, which
381385
has one file in it::
382386

383387
// 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
}

contributing/documentation/format.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,6 @@ Markup Format Use It to Display
118118
``html+twig`` Twig markup blended with HTML
119119
``html+php`` PHP code blended with HTML
120120
``ini`` INI
121-
``php-annotations`` PHP Annotations
122121
``php-attributes`` PHP Attributes
123122
``php-symfony`` PHP code example when using the Symfony framework
124123
``php-standalone`` PHP code to be used in any PHP application using standalone Symfony components

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([

0 commit comments

Comments
 (0)