Skip to content

Commit 2abb9aa

Browse files
committed
[Security] Add PHP Attribute example to controller
1 parent e31a19d commit 2abb9aa

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
@@ -1089,6 +1089,24 @@ Next, you'll need to create a route for this URL (but not a controller):
10891089
}
10901090
}
10911091
1092+
.. code-block:: php-attributes
1093+
1094+
// src/Controller/SecurityController.php
1095+
namespace App\Controller;
1096+
1097+
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
1098+
use Symfony\Component\Routing\Annotation\Route;
1099+
1100+
class SecurityController extends AbstractController
1101+
{
1102+
#[Route('/logout', name: 'app_logout', methods: ['GET'])]
1103+
public function logout()
1104+
{
1105+
// controller can be blank: it will never be executed!
1106+
throw new \Exception('Don\'t forget to activate logout in security.yaml');
1107+
}
1108+
}
1109+
10921110
.. code-block:: yaml
10931111
10941112
# config/routes.yaml

0 commit comments

Comments
 (0)