inetprocess/silex-recaptcha-service-provider

v1.0.0 2018-01-19 11:09 UTC

This package is not auto-updated.

Last update: 2024-11-05 04:49:52 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