Skip to content

Commit 439b398

Browse files
committed
Merge branch '6.0' into 6.1
* 6.0: Replace Route annotations with attributes, remove Route annotation configuration block
2 parents 39fba95 + db90899 commit 439b398

18 files changed

+49
-696
lines changed

configuration/micro_kernel_trait.rst

+1-3
Original file line numberDiff line numberDiff line change
@@ -297,9 +297,7 @@ has one file in it::
297297

298298
class MicroController extends AbstractController
299299
{
300-
/**
301-
* @Route("/random/{limit}")
302-
*/
300+
#[Route('/random/{limit}')]
303301
public function randomNumber(int $limit): Response
304302
{
305303
$number = random_int(0, $limit);

controller/service.rst

-37
Original file line numberDiff line numberDiff line change
@@ -39,24 +39,6 @@ a service like: ``App\Controller\HelloController::index``:
3939

4040
.. configuration-block::
4141

42-
.. code-block:: php-annotations
43-
44-
// src/Controller/HelloController.php
45-
namespace App\Controller;
46-
47-
use Symfony\Component\Routing\Annotation\Route;
48-
49-
class HelloController
50-
{
51-
/**
52-
* @Route("/hello", name="hello", methods={"GET"})
53-
*/
54-
public function index()
55-
{
56-
// ...
57-
}
58-
}
59-
6042
.. code-block:: php-attributes
6143
6244
// src/Controller/HelloController.php
@@ -118,25 +100,6 @@ which is a common practice when following the `ADR pattern`_
118100

119101
.. configuration-block::
120102

121-
.. code-block:: php-annotations
122-
123-
// src/Controller/Hello.php
124-
namespace App\Controller;
125-
126-
use Symfony\Component\HttpFoundation\Response;
127-
use Symfony\Component\Routing\Annotation\Route;
128-
129-
/**
130-
* @Route("/hello/{name}", name="hello")
131-
*/
132-
class Hello
133-
{
134-
public function __invoke($name = 'World')
135-
{
136-
return new Response(sprintf('Hello %s!', $name));
137-
}
138-
}
139-
140103
.. code-block:: php-attributes
141104
142105
// src/Controller/Hello.php

controller/soap_web_service.rst

+1-3
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,7 @@ can be retrieved via ``/soap?wsdl``::
7171

7272
class HelloServiceController extends AbstractController
7373
{
74-
/**
75-
* @Route("/soap")
76-
*/
74+
#[Route('/soap')]
7775
public function index(HelloService $helloService)
7876
{
7977
$soapServer = new \SoapServer('/path/to/hello.wsdl');

controller/upload_file.rst

+1-3
Original file line numberDiff line numberDiff line change
@@ -133,9 +133,7 @@ Finally, you need to update the code of the controller that handles the form::
133133

134134
class ProductController extends AbstractController
135135
{
136-
/**
137-
* @Route("/product/new", name="app_product_new")
138-
*/
136+
#[Route('/product/new', name: 'app_product_new')]
139137
public function new(Request $request, SluggerInterface $slugger)
140138
{
141139
$product = new Product();

lock.rst

+2-6
Original file line numberDiff line numberDiff line change
@@ -180,9 +180,7 @@ To lock the default resource, autowire the lock factory using
180180

181181
class PdfController extends AbstractController
182182
{
183-
/**
184-
* @Route("/download/terms-of-use.pdf")
185-
*/
183+
#[Route('/download/terms-of-use.pdf')]
186184
public function downloadPdf(LockFactory $factory, MyPdfGeneratorService $pdf)
187185
{
188186
$lock = $factory->createLock('pdf-creation');
@@ -221,9 +219,7 @@ processes asking for the same ``$version``::
221219

222220
class PdfController extends AbstractController
223221
{
224-
/**
225-
* @Route("/download/{version}/terms-of-use.pdf")
226-
*/
222+
#[Route('/download/{version}/terms-of-use.pdf')]
227223
public function downloadPdf($version, LockFactory $lockFactory, MyPdfGeneratorService $pdf)
228224
{
229225
$lock = $lockFactory->createLock($version);

notifier/chatters.rst

+1-3
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,7 @@ you to send messages to chat services like Slack or Telegram::
1717

1818
class CheckoutController extends AbstractController
1919
{
20-
/**
21-
* @Route("/checkout/thankyou")
22-
*/
20+
#[Route('/checkout/thankyou')]
2321
public function thankyou(ChatterInterface $chatter)
2422
{
2523
$message = (new ChatMessage('You got a new invoice for 15 EUR.'))

notifier/texters.rst

+1-3
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@ you to send SMS messages::
1616

1717
class SecurityController
1818
{
19-
/**
20-
* @Route("/login/success")
21-
*/
19+
#[Route('/login/success')]
2220
public function loginSuccess(TexterInterface $texter)
2321
{
2422
$sms = new SmsMessage(

page_creation.rst

+1-21
Original file line numberDiff line numberDiff line change
@@ -106,24 +106,6 @@ You can now add your route directly *above* the controller:
106106

107107
.. configuration-block::
108108

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(): Response
122-
{
123-
// this looks exactly the same
124-
}
125-
}
126-
127109
.. code-block:: php-attributes
128110
129111
// src/Controller/LuckyController.php
@@ -257,9 +239,7 @@ variable so you can use it in Twig::
257239

258240
class LuckyController extends AbstractController
259241
{
260-
/**
261-
* @Route("/lucky/number")
262-
*/
242+
#[Route('/lucky/number')]
263243
public function number(): Response
264244
{
265245
$number = random_int(0, 100);

quick_tour/the_big_picture.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ Instead, add the route *right above* the controller method:
171171
}
172172
}
173173
174-
This works just like before! But by using annotations, the route and controller
174+
This works just like before! But by using attributes, the route and controller
175175
live right next to each other. Need another page? Add another route and method
176176
in ``DefaultController``::
177177

0 commit comments

Comments
 (0)