Skip to content

Commit 3e7578a

Browse files
committed
minor #15007 [Security] Add PHP Attribute route example to the controller (wkania)
This PR was merged into the 5.2 branch. Discussion ---------- [Security] Add PHP Attribute route example to the controller <!-- If your pull request fixes a BUG, use the oldest maintained branch that contains the bug (see https://symfony.com/releases for the list of maintained branches). If your pull request documents a NEW FEATURE, use the same Symfony branch where the feature was introduced (and `5.x` for features of unreleased versions). --> Commits ------- 2abb9aa [Security] Add PHP Attribute example to controller
2 parents f245120 + 2abb9aa commit 3e7578a

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)