mirror of
https://github.com/alrayyes/wiki.git
synced 2024-11-25 04:56:23 +00:00
670 B
670 B
id | title |
---|---|
c25c1315-47c9-484e-ba03-59c44c720cb5 | Route |
Description
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()
{
// ...
}
}