PHP code example of dmishh / recaptcha-bundle

1. Go to this page and download the library: Download dmishh/recaptcha-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/ */

    

dmishh / recaptcha-bundle example snippets


    

    // in AppKernel::registerBundles()
    $bundles = array(
        // ...
        new Dmishh\Bundle\RecaptchaBundle\RecaptchaBundle()
    );
    
bash
    php composer.phar update
    
 php


// your form ...

public function buildForm(FormBuilder $builder, array $options)
{
    // ...
    $builder->add('recaptcha', 'recaptcha');
}
 php


// your form ...

public function buildForm(FormBuilder $builder, array $options)
{
    // ...
    $builder->add('recaptcha', 'recaptcha', array(
        'widget_options' => array(
            'theme' => 'clean'
        )
    ));
}
 php


// your form ...

public function buildForm(FormBuilder $builder, array $options)
{
    // ...
    $builder->add('recaptcha', 'recaptcha', array(
        // only for disabling validation
        'constraints'   => array()
    ));
}
 php


// your controller ...

public function yourAction(Request $request) {
    // ...
    $recaptcha = $this->createForm($this->get('form.type.recaptcha'));

    return array(
        // ...
        'recaptcha' => $recaptcha->createView()
    );
}