- PHP
>=5.5
- KrtvCsrfValidatorBundle's
0.4.x
compatible with symfony (>=2.7
versions). - Doctrine is required
- Add extra annotation for auto validation CSRF-tokens to your controller actions
Pretty simple with Composer, add:
{
"require": {
"korotovsky/csrf-validator-bundle": "0.4.*"
}
}
For latest version (UNSTABLE) use
{
"require": {
"korotovsky/csrf-validator-bundle": "~0.4.0@dev"
}
}
- No specific configuration is needed!
// app/AppKernel.php
public function registerBundles()
{
return array(
// ...
new Krtv\Bundle\CsrfValidatorBundle\KrtvCsrfValidatorBundle(),
// ...
);
}
Just add annotation to your controller action
// Acme\MainBundle\Controller\DefaultController.php
use Krtv\Bundle\CsrfValidatorBundle\Annotations as Krtv;
/**
* @Krtv\Csrf(intention="your_intention")
* @return Response
*/
public function importantZoneAction()
{
// some code here ...
return new Response();
}
<a href="{{ path('_some_route', {'token': csrf_token('your_intention')}) }}">Subscribe!</a>