gregwar/captcha-bundle
Symfony bundle that adds a Captcha form type powered by gregwar/captcha. Simple Composer install, Flex auto-registration, and optional global YAML config. Supports inline embedded images by default or file-based captchas with cleanup/expiration options.
gregwar/captcha-bundle is a Symfony-specific bundle that extends the Symfony Form Component, making it a natural fit for applications built on Symfony 6.x–8.x (or legacy versions). It abstracts CAPTCHA generation into a reusable form type, aligning with Symfony’s declarative configuration and dependency injection principles.gregwar/captcha library is standalone, allowing for non-Symfony usage (e.g., CLI tools, custom PHP scripts). This modularity ensures the bundle doesn’t impose tight coupling beyond Symfony’s ecosystem.symfony/webpack-encore (for frontend CAPTCHAs) or hwi/oauth-bundle (for OAuth-based verification), this bundle is specialized for traditional text/image CAPTCHAs, which may be overkill for SPAs or headless APIs but sufficient for server-rendered forms.GregwarCaptchaType that can be dropped into any Symfony form.symfony/form and gregwar/captcha. Potential conflicts with other CAPTCHA libraries (e.g., friendsofsymfony/user-bundle) are unlikely unless the app already uses a competing solution.Content-Security-Policy headers.gregwar/captcha relies on GD library, which may face deprecation in future PHP versions.symfony/security-csrf) if this bundle stagnates?php-gd is enabled (php -m | grep gd).symfony/security-csrf + custom middleware.symfony/rate-limiter) may suffice./contact, /register).composer require gregwar/captcha-bundle
config/bundles.php.config/packages/gregwar_captcha.yaml:
gregwar_captcha:
width: 120
height: 40
difficulty: 3
storage:
type: session # or 'redis' for distributed systems
GregwarCaptchaType to any form:
use Gregwar\CaptchaBundle\Form\Type\CaptchaType;
$builder->add('captcha', CaptchaType::class);
captcha.html.twig).$form->handleRequest($request);
if ($form->isSubmitted() && !$form->isValid()) {
// Handle CAPTCHA failure (e.g., show error)
}
Gregwar\Captcha\Captcha to test form validation.siege or k6).2.2.*.php -r "if(!extension_loaded('gd')) die('GD not installed'); echo 'GD OK';"
captcha table exists (or extend the bundle).gregwar_captcha:
storage:
type: redis
host: redis
port: 6379
How can I help you explore Laravel packages today?