Skip to content

Commit 90936ab

Browse files
committed
Minor reword
1 parent 09b05b3 commit 90936ab

File tree

1 file changed

+36
-39
lines changed

1 file changed

+36
-39
lines changed

page_creation.rst

Lines changed: 36 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -94,12 +94,9 @@ to creating a page?
9494
Annotation Routes
9595
-----------------
9696

97-
.. caution::
98-
99-
If you use PHP8 or later, you do not need to install annotations package and instead of annotations, you can use structured metadata with PHP's native syntax (Attributes)
100-
10197
Instead of defining your route in YAML, Symfony also allows you to use *annotation*
102-
routes. To do this, install the annotations package:
98+
or *attribute* routes. Attributes are built-in in PHP starting from PHP 8. In earlier
99+
PHP versions you can use annotations. To do this, install the annotations package:
103100

104101
.. code-block:: terminal
105102
@@ -109,42 +106,42 @@ You can now add your route directly *above* the controller:
109106

110107
.. configuration-block::
111108

112-
.. code-block:: Annotations
113-
114-
// src/Controller/LuckyController.php
115-
116-
// ...
117-
+ use Symfony\Component\Routing\Annotation\Route;
118-
119-
class LuckyController
120-
{
121-
+ /**
122-
+ * @Route("/lucky/number")
123-
+ */
124-
public function number()
125-
{
126-
// this looks exactly the same
127-
}
128-
}
129-
130-
.. code-block:: Attributes
131-
132-
// src/Controller/LuckyController.php
133-
134-
// ...
135-
+ use Symfony\Component\Routing\Annotation\Route;
136-
137-
class LuckyController
138-
{
139-
+ #[Route('/lucky/number')
140-
public function number()
141-
{
142-
// this looks exactly the same
143-
}
144-
}
109+
.. code-block:: php-annotations
110+
111+
// src/Controller/LuckyController.php
112+
113+
// ...
114+
+ use Symfony\Component\Routing\Annotation\Route;
115+
116+
class LuckyController
117+
{
118+
+ /**
119+
+ * @Route("/lucky/number")
120+
+ */
121+
public function number()
122+
{
123+
// this looks exactly the same
124+
}
125+
}
126+
127+
.. code-block:: php-attributes
128+
129+
// src/Controller/LuckyController.php
130+
131+
// ...
132+
+ use Symfony\Component\Routing\Annotation\Route;
133+
134+
class LuckyController
135+
{
136+
+ #[Route('/lucky/number')
137+
public function number()
138+
{
139+
// this looks exactly the same
140+
}
141+
}
145142
146143
That's it! The page - http://localhost:8000/lucky/number will work exactly
147-
like before! Annotations are the recommended way to configure routes.
144+
like before! Annotations/attributes are the recommended way to configure routes.
148145

149146
.. _flex-quick-intro:
150147

0 commit comments

Comments
 (0)