PHP code example of inetprocess / silex-recaptcha-service-provider

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

    

inetprocess / silex-recaptcha-service-provider example snippets


use Silex\Provider\FormServiceProvider;
use Silex\Provider\ValidatorServiceProvider;
use Silex\Provider\TwigServiceProvider;
use Sergiors\Silex\Provider\RecaptchaServiceProvider;

$app->register(new FormServiceProvider());
$app->register(new ValidatorServiceProvider());
$app->register(new TwigServiceProvider());
$app->register(new RecaptchaServiceProvider(), [
    'recaptcha.sitekey' => '',
    'recaptcha.secretkey' => '',
]);

use Symfony\Component\Form\Extension\Core\Type\FormType;
use Sergiors\Silex\Form\Type\RecaptchaType;
use Sergiors\Silex\Validator\Constraints\Recaptcha;

$form = $app['form.factory']->createBuilder(FormType::class, [])
    ->add('recaptcha', RecaptchaType::class, [
        'constraints' => [
            new Recaptcha()
        ]
    ])
    ->getForm();