@@ -24,12 +24,12 @@ because it's convenient to put the route and controller in the same place.
24
24
Creating Routes as Attributes or Annotations
25
25
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
26
26
27
- On PHP 8, you can use native attributes to configure routes right away. On
28
- PHP 7, where attributes are not available, you can use annotations instead,
29
- provided by the Doctrine Annotations library .
27
+ PHP attributes and annotations allow to define routes next to the code of the
28
+ :doc: ` controllers < /controller >` associated to those routes. Attributes are
29
+ native in PHP 8 and higher versions, so you can use them right away .
30
30
31
- In case you want to use annotations instead of attributes, run this command
32
- once in your application to enable them :
31
+ In PHP 7 and earlier versions you can use annotations (via the Doctrine Annotations
32
+ library), but first you'll need to install the following dependency in your project :
33
33
34
34
.. code-block :: terminal
35
35
@@ -41,10 +41,11 @@ once in your application to enable them:
41
41
Symfony 5.2. Prior to this, Doctrine Annotations were the only way to
42
42
annotate controller actions with routing configuration.
43
43
44
- If you are using :ref: `Symfony Flex <symfony-flex >` this command also
45
- creates the following configuration file and you're done. If you aren't
46
- using flex or want to use attributes, the file has to be added manually.
47
- ``type: annotation `` applies for attributes, too.
44
+ Regardless of what you use (attributes or annotations) you need to add a bit of
45
+ configuration to your project before using them. If you installed the annotations
46
+ dependency and your project uses :ref: `Symfony Flex <symfony-flex >`, this file
47
+ is already created for you. Otherwise, create the following file manually
48
+ (the ``type: annotation `` option also applies to attributes, so you can keep it):
48
49
49
50
.. code-block :: yaml
50
51
0 commit comments