PHP code example of depthbomb / csrf-bundle
1. Go to this page and download the library: Download depthbomb/csrf-bundle library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
depthbomb / csrf-bundle example snippets
namespace App\Controller
// ...
use Depthbomb\CsrfBundle\Attribute\CsrfProtected;
#[CsrfProtected('my token')] // protect entire controllers
class MyController extends AbstractController
{
// ...
#[CsrfProtected('my token')] // protect specific actions
public function myAction(): Response
{
// ...
}
}
// in a service/controller
$my_token = $this->tokenManager->getToken('my token');