phpmob/recaptcha-bundle

Spam protect with google reCAPTCHA

Maintainers

👁 liverbool

Package info

github.com/phpmob/recaptcha-bundle

Homepage

pkg:composer/phpmob/recaptcha-bundle

Statistics

Installs: 169

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

1.1.1 2018-02-05 10:26 UTC

Requires (Dev)

Suggests

None

Provides

None

Conflicts

None

Replaces

None

MIT 3a434fe770b3eabba1ca0f0affdc1371c3f92c0b

  • Ishmael Doss <nukboon.woop@gmail.com>

recaptchagooglespam-protect

This package is auto-updated.

Last update: 2026-06-19 03:11:28 UTC


README

PhpMobReCaptchaBundle is a spam protection using google reCaptcha.

Installing

Installing via composer is recommended.

"require": {
 "phpmob/recaptcha-bundle": "~1.1"
}

Enabling

And then enable bundle in AppKernel.php

public function registerBundles()
{
 $bundles = [
 ...
 new \PhpMob\ReCaptchaBundle\PhpMobReCaptchaBundle(),
 ];
}

Usage

In order to using it you need to setup a bit, First create google recatpcha via https://www.google.com/recaptcha/admin and then config in your symfony app.

  1. Configuration
phpmob_recaptcha
 site_key: <google_recaptcha_site_key>
 secret_key: <google_recaptcha_secret_key>
 # optional
 enabled: true/false # toggle enable or disable to using it
 verify_host: true/false # strict verify hostname (not allow to submit from remote host)
 theme: light/dark # default light
  1. Using
<?php

use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use PhpMob\ReCaptchaBundle\Form\Type\RecaptchaType;
use PhpMob\ReCaptchaBundle\Validator\Constraints\IsValid;

class YourType extends AbstractType
{
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
 $builder
 ->add('field', TextType::class, [])

 ->add("recaptcha", RecaptchaType::class, [
 'mapped' => false,
 'label' => false,
 "constraints" => [
 new IsValid(['groups' => ['some_group_if_need']])
 ]
 ])
 ;
 }
}

2.1 Use with Login Form

phpmob_recaptcha
 login:
 enabled: true
 firewall: your_firewall_section_name
<?php

use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\Extension\Core\Type\PasswordType;
use PhpMob\ReCaptchaBundle\Form\Type\RecaptchaType;
use PhpMob\ReCaptchaBundle\Validator\Constraints\IsValid;

class UserLoginType extends AbstractType
{
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
 $builder
 ->add('_username', TextType::class, [])
 ->add('_password', PasswordType::class, [])

 ->add("recaptcha", RecaptchaType::class, [
 'mapped' => false,
 'label' => false,
 ])
 ;
 }
}

That was it!

License

MIT