sergiors/recaptcha-service-provider

dev-master 2016-11-11 16:12 UTC

This package is not auto-updated.

Last update: 2024-12-22 02:16:56 UTC


README

Register your site in Google reCAPTCHA

Install

composer require sergiors/recaptcha-service-provider "dev-master"
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' => '',
]);

Form

More details how to use form

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();

In your template

{{ form_widget(form.recaptcha) }}

License

MIT