Skip to content

Replace Annotation\Route with Attribute\Route #19623

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cache.rst
Original file line number Diff line number Diff line change
Expand Up @@ -910,7 +910,7 @@ In the following example, the value is requested from a controller::

use App\Cache\CacheComputation;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Routing\Attribute\Route;
use Symfony\Contracts\Cache\CacheInterface;
use Symfony\Contracts\Cache\ItemInterface;

Expand Down
4 changes: 2 additions & 2 deletions configuration/micro_kernel_trait.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Next, create an ``index.php`` file that defines the kernel class and runs it:
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Kernel as BaseKernel;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Routing\Attribute\Route;

require __DIR__.'/vendor/autoload.php';

Expand Down Expand Up @@ -390,7 +390,7 @@ has one file in it::

use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Routing\Attribute\Route;

class MicroController extends AbstractController
{
Expand Down
4 changes: 2 additions & 2 deletions controller.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class::
namespace App\Controller;

use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Routing\Attribute\Route;

class LuckyController
{
Expand Down Expand Up @@ -763,7 +763,7 @@ method::

use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Routing\Attribute\Route;
use Symfony\Component\WebLink\Link;

class HomepageController extends AbstractController
Expand Down
6 changes: 3 additions & 3 deletions controller/service.rst
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ apply the ``controller.service_arguments`` tag to your controller services::

use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Attribute\AsController;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Routing\Attribute\Route;

#[AsController]
class HelloController
Expand Down Expand Up @@ -95,7 +95,7 @@ a service like: ``App\Controller\HelloController::index``:
namespace App\Controller;

use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Routing\Attribute\Route;

class HelloController
{
Expand Down Expand Up @@ -157,7 +157,7 @@ which is a common practice when following the `ADR pattern`_
namespace App\Controller;

use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Routing\Attribute\Route;

#[Route('/hello/{name}', name: 'hello')]
class Hello
Expand Down
2 changes: 1 addition & 1 deletion controller/upload_file.rst
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ Finally, you need to update the code of the controller that handles the form::
use Symfony\Component\HttpFoundation\File\UploadedFile;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Routing\Attribute\Route;
use Symfony\Component\String\Slugger\SluggerInterface;

class ProductController extends AbstractController
Expand Down
6 changes: 3 additions & 3 deletions controller/value_resolver.rst
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ Symfony ships with the following value resolvers in the
namespace App\Controller;

use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Routing\Attribute\Route;
use Symfony\Component\Uid\UuidV4;

class DefaultController
Expand Down Expand Up @@ -201,7 +201,7 @@ In addition, some components, bridges and official bundles provide other value r
namespace App\Controller;

use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Routing\Attribute\Route;

class DefaultController
{
Expand Down Expand Up @@ -250,7 +250,7 @@ lets you do this by "targeting" the resolver you want::
use Symfony\Component\HttpFoundation\Session\SessionInterface;
use Symfony\Component\HttpKernel\Attribute\ValueResolver;
use Symfony\Component\HttpKernel\Controller\ArgumentResolver\SessionValueResolver;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Routing\Attribute\Route;

class SessionController
{
Expand Down
14 changes: 7 additions & 7 deletions doctrine.rst
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ and save it::
use App\Entity\Product;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Routing\Attribute\Route;

class ProductController extends AbstractController
{
Expand Down Expand Up @@ -438,7 +438,7 @@ Consider the following controller code::

use App\Entity\Product;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Routing\Attribute\Route;
use Symfony\Component\Validator\Validator\ValidatorInterface;
// ...

Expand Down Expand Up @@ -502,7 +502,7 @@ be able to go to ``/product/1`` to see your new product::
use App\Entity\Product;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Routing\Attribute\Route;
// ...

class ProductController extends AbstractController
Expand Down Expand Up @@ -535,7 +535,7 @@ and injected by the dependency injection container::
use App\Entity\Product;
use App\Repository\ProductRepository;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Routing\Attribute\Route;
// ...

class ProductController extends AbstractController
Expand Down Expand Up @@ -624,7 +624,7 @@ automatically! You can simplify the controller to::
use App\Entity\Product;
use App\Repository\ProductRepository;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Routing\Attribute\Route;
// ...

class ProductController extends AbstractController
Expand Down Expand Up @@ -700,7 +700,7 @@ the ``EntityValueResolver`` behavior by using the `MapEntity options`_ ::
use App\Entity\Product;
use Symfony\Bridge\Doctrine\Attribute\MapEntity;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Routing\Attribute\Route;
// ...

class ProductController extends AbstractController
Expand Down Expand Up @@ -841,7 +841,7 @@ with any PHP model::
use App\Repository\ProductRepository;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Routing\Attribute\Route;
// ...

class ProductController extends AbstractController
Expand Down
2 changes: 1 addition & 1 deletion doctrine/associations.rst
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ Now you can see this new code in action! Imagine you're inside a controller::
use App\Entity\Product;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Routing\Attribute\Route;

class ProductController extends AbstractController
{
Expand Down
4 changes: 2 additions & 2 deletions mailer.rst
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ and create an :class:`Symfony\\Component\\Mime\\Email` object::
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Mailer\MailerInterface;
use Symfony\Component\Mime\Email;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Routing\Attribute\Route;

class MailerController extends AbstractController
{
Expand Down Expand Up @@ -1629,7 +1629,7 @@ Here's an example of making one available to download::
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\ResponseHeaderBag;
use Symfony\Component\Mime\DraftEmail;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Routing\Attribute\Route;

class DownloadEmailController extends AbstractController
{
Expand Down
2 changes: 1 addition & 1 deletion page_creation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ metadata to code):
// src/Controller/LuckyController.php

// ...
+ use Symfony\Component\Routing\Annotation\Route;
+ use Symfony\Component\Routing\Attribute\Route;

class LuckyController
{
Expand Down
4 changes: 2 additions & 2 deletions quick_tour/flex_recipes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ Thanks to Flex, after one command, you can start using Twig immediately:
// src/Controller/DefaultController.php
namespace App\Controller;

use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Routing\Attribute\Route;
- use Symfony\Component\HttpFoundation\Response;
+ use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;

Expand Down Expand Up @@ -157,7 +157,7 @@ Are you building an API? You can already return JSON from any controller::

use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Routing\Attribute\Route;

class DefaultController extends AbstractController
{
Expand Down
4 changes: 2 additions & 2 deletions quick_tour/the_architecture.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ use the logger in a controller, add a new argument type-hinted with ``LoggerInte
use Psr\Log\LoggerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Routing\Attribute\Route;

class DefaultController extends AbstractController
{
Expand Down Expand Up @@ -108,7 +108,7 @@ Great! You can use it immediately in your controller::
use Psr\Log\LoggerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Routing\Attribute\Route;

class DefaultController extends AbstractController
{
Expand Down
4 changes: 2 additions & 2 deletions quick_tour/the_big_picture.rst
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ Instead, add the route *right above* the controller method:
namespace App\Controller;

use Symfony\Component\HttpFoundation\Response;
+ use Symfony\Component\Routing\Annotation\Route;
+ use Symfony\Component\Routing\Attribute\Route;

class DefaultController
{
Expand All @@ -173,7 +173,7 @@ in ``DefaultController``::
namespace App\Controller;

use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Routing\Attribute\Route;

class DefaultController
{
Expand Down
Loading