backend2-plus / google-captcha-bundle
Google reCAPTCHA bundle for Symfony
Installs: 5
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
Type:symfony-bundle
Requires
- php: >=8.0
- symfony/dependency-injection: ^6.0|^7.0
- symfony/framework-bundle: ^6.0|^7.0
This package is auto-updated.
Last update: 2025-09-05 20:40:44 UTC
README
Simple Symfony bundle for Google reCAPTCHA integration.
Installation
composer require sasa1007/google-captcha-bundle
Note: After installation, you need to manually configure the bundle as described below.
Configuration
Create configuration file config/packages/google_captcha.yaml
:
google_captcha: secret: '%env(GOOGLE_CAPTCHA_SECRET)%'
Add to your .env
file:
GOOGLE_CAPTCHA_SECRET=your_google_recaptcha_secret_key
Note: Replace your_google_recaptcha_secret_key
with your actual Google reCAPTCHA secret key from Google reCAPTCHA Admin Console.
Usage
use BeckUp\GoogleCaptchaBundle\Service\GoogleCaptchaService; class YourController extends AbstractController { public function someAction(Request $request, GoogleCaptchaService $captchaService) { $result = $captchaService->verify($request); if ($result->success) { // reCAPTCHA passed } else { // reCAPTCHA failed } } }
Frontend
Add Google reCAPTCHA script to your template:
<script src="https://www.google.com/recaptcha/api.js" async defer></script> <div class="g-recaptcha" data-sitekey="your_site_key"></div>
Uninstallation
To remove the bundle:
- Delete configuration file:
rm config/packages/google_captcha.yaml
- Remove from composer:
composer remove sasa1007/google-captcha-bundle
Note: The bundle is automatically unregistered and service definitions are removed when you uninstall the package.