Skip to content

Commit 1dee796

Browse files
committed
Merge branch '5.2' into 5.x
* 5.2: [Security] Add PHP Attribute example to controller
2 parents 0b45a08 + 3e7578a commit 1dee796

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

security.rst

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1088,6 +1088,24 @@ Next, you'll need to create a route for this URL (but not a controller):
10881088
}
10891089
}
10901090
1091+
.. code-block:: php-attributes
1092+
1093+
// src/Controller/SecurityController.php
1094+
namespace App\Controller;
1095+
1096+
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
1097+
use Symfony\Component\Routing\Annotation\Route;
1098+
1099+
class SecurityController extends AbstractController
1100+
{
1101+
#[Route('/logout', name: 'app_logout', methods: ['GET'])]
1102+
public function logout()
1103+
{
1104+
// controller can be blank: it will never be executed!
1105+
throw new \Exception('Don\'t forget to activate logout in security.yaml');
1106+
}
1107+
}
1108+
10911109
.. code-block:: yaml
10921110
10931111
# config/routes.yaml

0 commit comments

Comments
 (0)