wiki/content/20201117105045-rout.md

43 lines
687 B
Markdown
Raw Normal View History

2024-05-06 20:40:05 +00:00
---
2024-10-29 18:27:12 +00:00
date: 2020-11-17
2024-05-06 20:40:05 +00:00
id: c25c1315-47c9-484e-ba03-59c44c720cb5
title: Route
---
# Description
[PHP Attributes](20201110100420-php_attributes) can be used to define
routing.
# Syntax
``` php
// BEFORE: annotations defined with Doctrine Annotations library
use Symfony\Component\Routing\Annotation\Route;
class SomeController
{
/**
* @Route("/path", name="action")
*/
public function someAction()
{
// ...
}
}
```
``` php
// AFTER: annotations defined with PHP 8 attributes
use Symfony\Component\Routing\Annotation\Route;
class SomeController
{
#[Route('/path', name: 'action')]
public function someAction()
{
// ...
}
}
```