diff --git a/security.rst b/security.rst index 3b9341a07d6..18d0344f42e 100644 --- a/security.rst +++ b/security.rst @@ -1089,6 +1089,24 @@ Next, you'll need to create a route for this URL (but not a controller): } } + .. code-block:: php-attributes + + // src/Controller/SecurityController.php + namespace App\Controller; + + use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; + use Symfony\Component\Routing\Annotation\Route; + + class SecurityController extends AbstractController + { + #[Route('/logout', name: 'app_logout', methods: ['GET'])] + public function logout() + { + // controller can be blank: it will never be executed! + throw new \Exception('Don\'t forget to activate logout in security.yaml'); + } + } + .. code-block:: yaml # config/routes.yaml