diff --git a/cache.rst b/cache.rst index d3459ea0d06..88f76245536 100644 --- a/cache.rst +++ b/cache.rst @@ -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; diff --git a/configuration/micro_kernel_trait.rst b/configuration/micro_kernel_trait.rst index 890f3fc8b9c..4b538f1b6e4 100644 --- a/configuration/micro_kernel_trait.rst +++ b/configuration/micro_kernel_trait.rst @@ -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'; @@ -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 { diff --git a/controller.rst b/controller.rst index 5e4d97864ac..40ed6bfc07f 100644 --- a/controller.rst +++ b/controller.rst @@ -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 { @@ -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 diff --git a/controller/service.rst b/controller/service.rst index b0a552252b5..88af093ff29 100644 --- a/controller/service.rst +++ b/controller/service.rst @@ -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 @@ -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 { @@ -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 diff --git a/controller/upload_file.rst b/controller/upload_file.rst index c05e78997ba..73346408e4a 100644 --- a/controller/upload_file.rst +++ b/controller/upload_file.rst @@ -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 diff --git a/controller/value_resolver.rst b/controller/value_resolver.rst index 209b9c05a01..3e888793c15 100644 --- a/controller/value_resolver.rst +++ b/controller/value_resolver.rst @@ -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 @@ -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 { @@ -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 { diff --git a/doctrine.rst b/doctrine.rst index 4f4d5136a84..dee7e694897 100644 --- a/doctrine.rst +++ b/doctrine.rst @@ -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 { @@ -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; // ... @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 diff --git a/doctrine/associations.rst b/doctrine/associations.rst index ba34dbf3693..a9cc365d48f 100644 --- a/doctrine/associations.rst +++ b/doctrine/associations.rst @@ -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 { diff --git a/mailer.rst b/mailer.rst index 53b9d88b6f1..527fa3d3871 100644 --- a/mailer.rst +++ b/mailer.rst @@ -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 { @@ -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 { diff --git a/page_creation.rst b/page_creation.rst index 0bba49938f5..f8b2fdaf251 100644 --- a/page_creation.rst +++ b/page_creation.rst @@ -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 { diff --git a/quick_tour/flex_recipes.rst b/quick_tour/flex_recipes.rst index a71961d78af..c058008b84a 100644 --- a/quick_tour/flex_recipes.rst +++ b/quick_tour/flex_recipes.rst @@ -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; @@ -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 { diff --git a/quick_tour/the_architecture.rst b/quick_tour/the_architecture.rst index a4154d822b1..a323461885d 100644 --- a/quick_tour/the_architecture.rst +++ b/quick_tour/the_architecture.rst @@ -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 { @@ -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 { diff --git a/quick_tour/the_big_picture.rst b/quick_tour/the_big_picture.rst index e78cdf4e698..34bea4f82cc 100644 --- a/quick_tour/the_big_picture.rst +++ b/quick_tour/the_big_picture.rst @@ -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 { @@ -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 { diff --git a/routing.rst b/routing.rst index 0c3c99c0381..02fdf17bf04 100644 --- a/routing.rst +++ b/routing.rst @@ -64,7 +64,7 @@ do so, create a :doc:`controller class ` like the following: use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\Response; - use Symfony\Component\Routing\Annotation\Route; + use Symfony\Component\Routing\Attribute\Route; class BlogController extends AbstractController { @@ -178,7 +178,7 @@ Use the ``methods`` option to restrict the verbs each route should respond to: use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\Response; - use Symfony\Component\Routing\Annotation\Route; + use Symfony\Component\Routing\Attribute\Route; class BlogApiController extends AbstractController { @@ -269,7 +269,7 @@ arbitrary matching logic: 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 { @@ -505,7 +505,7 @@ For example, the route to display the blog post contents is defined as ``/blog/{ use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\Response; - use Symfony\Component\Routing\Annotation\Route; + use Symfony\Component\Routing\Attribute\Route; class BlogController extends AbstractController { @@ -584,7 +584,7 @@ the ``{page}`` parameter using the ``requirements`` option: use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\Response; - use Symfony\Component\Routing\Annotation\Route; + use Symfony\Component\Routing\Attribute\Route; class BlogController extends AbstractController { @@ -702,7 +702,7 @@ concise, but it can decrease route readability when requirements are complex: use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\Response; - use Symfony\Component\Routing\Annotation\Route; + use Symfony\Component\Routing\Attribute\Route; class BlogController extends AbstractController { @@ -769,7 +769,7 @@ other configuration formats they are defined with the ``defaults`` option: use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\Response; - use Symfony\Component\Routing\Annotation\Route; + use Symfony\Component\Routing\Attribute\Route; class BlogController extends AbstractController { @@ -854,7 +854,7 @@ parameter: use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\Response; - use Symfony\Component\Routing\Annotation\Route; + use Symfony\Component\Routing\Attribute\Route; class BlogController extends AbstractController { @@ -924,7 +924,7 @@ optional ``priority`` parameter in those routes to control their priority: namespace App\Controller; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; - use Symfony\Component\Routing\Annotation\Route; + use Symfony\Component\Routing\Attribute\Route; class BlogController extends AbstractController { @@ -973,7 +973,7 @@ controller action. Instead of ``string $slug``, add ``BlogPost $post``:: use App\Entity\BlogPost; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\Response; - use Symfony\Component\Routing\Annotation\Route; + use Symfony\Component\Routing\Attribute\Route; class BlogController extends AbstractController { @@ -1015,7 +1015,7 @@ convert them automatically to their scalar values. use App\Enum\OrderStatusEnum; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\Response; - use Symfony\Component\Routing\Annotation\Route; + use Symfony\Component\Routing\Attribute\Route; class OrderController extends AbstractController { @@ -1147,7 +1147,7 @@ the controllers of the routes: use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\Response; - use Symfony\Component\Routing\Annotation\Route; + use Symfony\Component\Routing\Attribute\Route; class BlogController extends AbstractController { @@ -1220,7 +1220,7 @@ A possible solution is to change the parameter requirements to be more permissiv 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 { @@ -1417,7 +1417,7 @@ when importing the routes. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\Response; - use Symfony\Component\Routing\Annotation\Route; + use Symfony\Component\Routing\Attribute\Route; #[Route('/blog', requirements: ['_locale' => 'en|es|fr'], name: 'blog_')] class BlogController extends AbstractController @@ -1597,7 +1597,7 @@ information in a controller via the ``Request`` object:: use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; - use Symfony\Component\Routing\Annotation\Route; + use Symfony\Component\Routing\Attribute\Route; class BlogController extends AbstractController { @@ -1793,7 +1793,7 @@ host name: use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\Response; - use Symfony\Component\Routing\Annotation\Route; + use Symfony\Component\Routing\Attribute\Route; class MainController extends AbstractController { @@ -1868,7 +1868,7 @@ multi-tenant applications) and these parameters can be validated too with use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\Response; - use Symfony\Component\Routing\Annotation\Route; + use Symfony\Component\Routing\Attribute\Route; class MainController extends AbstractController { @@ -1996,7 +1996,7 @@ avoids the need for duplicating routes, which also reduces the potential bugs: use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\Response; - use Symfony\Component\Routing\Annotation\Route; + use Symfony\Component\Routing\Attribute\Route; class CompanyController extends AbstractController { @@ -2175,7 +2175,7 @@ session shouldn't be used when matching a request: namespace App\Controller; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; - use Symfony\Component\Routing\Annotation\Route; + use Symfony\Component\Routing\Attribute\Route; class MainController extends AbstractController { @@ -2257,7 +2257,7 @@ that defines only one route. Consider the following class:: namespace App\Controller; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; - use Symfony\Component\Routing\Annotation\Route; + use Symfony\Component\Routing\Attribute\Route; final class MainController extends AbstractController { @@ -2286,7 +2286,7 @@ use the ``generateUrl()`` helper:: 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\Routing\Generator\UrlGeneratorInterface; class BlogController extends AbstractController @@ -2588,7 +2588,7 @@ each route explicitly: use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\Response; - use Symfony\Component\Routing\Annotation\Route; + use Symfony\Component\Routing\Attribute\Route; class SecurityController extends AbstractController { diff --git a/security.rst b/security.rst index d2bdc502659..99f364fbb31 100644 --- a/security.rst +++ b/security.rst @@ -750,7 +750,7 @@ First, create a controller for the login form: use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\Response; - use Symfony\Component\Routing\Annotation\Route; + use Symfony\Component\Routing\Attribute\Route; class LoginController extends AbstractController { @@ -1112,7 +1112,7 @@ create a controller for this path: use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\Response; - use Symfony\Component\Routing\Annotation\Route; + use Symfony\Component\Routing\Attribute\Route; class ApiLoginController extends AbstractController { diff --git a/security/login_link.rst b/security/login_link.rst index 160327cabbc..faa1d353514 100644 --- a/security/login_link.rst +++ b/security/login_link.rst @@ -87,7 +87,7 @@ intercept requests to this route: namespace App\Controller; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; - use Symfony\Component\Routing\Annotation\Route; + use Symfony\Component\Routing\Attribute\Route; class SecurityController extends AbstractController { @@ -148,7 +148,7 @@ this interface:: use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; 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\Security\Http\LoginLink\LoginLinkHandlerInterface; class SecurityController extends AbstractController diff --git a/service_container.rst b/service_container.rst index b627c772949..edb61fac2de 100644 --- a/service_container.rst +++ b/service_container.rst @@ -30,7 +30,7 @@ service's class or interface name. Want to :doc:`log ` something? No p 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 ProductController extends AbstractController { @@ -117,7 +117,7 @@ inside your controller:: use App\Service\MessageGenerator; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\Response; - use Symfony\Component\Routing\Annotation\Route; + use Symfony\Component\Routing\Attribute\Route; class ProductController extends AbstractController { diff --git a/service_container/autowiring.rst b/service_container/autowiring.rst index e20d0357f4f..1352f03475a 100644 --- a/service_container/autowiring.rst +++ b/service_container/autowiring.rst @@ -126,7 +126,7 @@ Now, you can use the ``TwitterClient`` service immediately in a controller:: use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; - use Symfony\Component\Routing\Annotation\Route; + use Symfony\Component\Routing\Attribute\Route; class DefaultController extends AbstractController { diff --git a/templates.rst b/templates.rst index 529f09b2a78..d8558c5872a 100644 --- a/templates.rst +++ b/templates.rst @@ -192,7 +192,7 @@ Consider the following routing configuration: // ... use Symfony\Component\HttpFoundation\Response; - use Symfony\Component\Routing\Annotation\Route; + use Symfony\Component\Routing\Attribute\Route; class BlogController extends AbstractController {