Register your site in Google reCAPTCHA
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' => '',
]);
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();
{{ form_widget(form.recaptcha) }}
MIT