Route

Description

[PHP Attributes](PHP Attributes) can be used to define routing.

Syntax

// BEFORE: annotations defined with Doctrine Annotations library
use Symfony\Component\Routing\Annotation\Route;

class SomeController
{
/**
* @Route(“/path”, name=“action”)
*/
public function someAction()
{
// …
}
}

// AFTER: annotations defined with PHP 8 attributes
use Symfony\Component\Routing\Annotation\Route;

class SomeController
{
#[Route(‘/path’, name: ‘action’)]
public function someAction()
{
// …
}
}