PHP code example of secit-pl / advanced-form-token-bundle

1. Go to this page and download the library: Download secit-pl/advanced-form-token-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/ */

    

secit-pl / advanced-form-token-bundle example snippets


class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = [
            ...
            new SecIT\AdvancedFormTokenBundle\AdvancedFormTokenBundle(),
        ];

        ...
    }
}



namespace App\Form;

use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Form\Extension\Core\Type as FormField;
use Symfony\Component\Validator\Constraints;

class ContactType extends AbstractType
{
    public function configureOptions(OptionsResolver $resolver)
    {
        $resolver->setDefaults([
            'javascript_csrf_protection' => true, // enable the JavaScript form token
            
            ...
        ]);
    }

    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        ...
    }
}

yaml
advanced_form_token:
    javascript_token:
        javascript_obfuscator: SecIT\AdvancedFormTokenBundle\JavaScript\TholuPhpPackerObfuscator