mirror of
https://github.com/alrayyes/wiki.git
synced 2024-11-29 14:36:22 +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()
{
// ...
}
}