florentingarnier/spam-protection-bundle
A Symfony bundle by Florentin Garnier that adds configurable spam protection to forms, helping block bot submissions and reduce junk input with minimal setup in Symfony applications.
composer.json: this is a Symfony Form-oriented spam-protection package, not a Laravel package with a service provider or publishable Laravel config. The v0.2.2 release adds symfony/translation-contracts and fixes the rejection message so it is translated instead of rendering the raw key florentin_garnier_spam_protection.invalid.FormRequest, middleware, or custom validation rule. Do not expect php artisan vendor:publish to expose package config.FormError messages are translated before the form theme renders them.florentin_garnier_spam_protection.invalid shown directly to visitors. It is a patch-level release with no apparent breaking changes.FormError using the florentin_garnier_spam_protection.invalid translation key. Customize the message by overriding the translation catalog, not by replacing the key with a hard-coded string.FormRequest:class SpamProtection implements ValidationRule
{
public function validate(string $attribute, mixed $value, Closure $fail): void
{
if (request()->filled('_honeypot')) {
$fail(__('florentin_garnier_spam_protection.invalid'));
}
$submittedAt = (int) request('_submitted_at', 0);
if ($submittedAt === 0 || now()->timestamp - $submittedAt < 3) {
$fail(__('florentin_garnier_spam_protection.invalid'));
}
}
}
lang/en/florentin_garnier_spam_protection.php with an invalid key, then render errors normally in Blade with @error.FormError messages after translation. Keep the package translation domain intact so overrides remain predictable.throttle middleware, CSRF protection, and content checks. The package pattern is a low-friction first line of defense, not a complete anti-spam system.symfony/translation-contracts dependency matters if you try to use this with Laravel’s translator. Laravel’s translator does not implement Symfony’s translator interfaces, so Symfony FormError translation may not use Laravel’s __() catalog automatically. You need an adapter or the Symfony Translation component if you use Symfony Form directly.bin/console cache:clear; in Laravel, php artisan cache:clear and php artisan config:clear may be needed depending on how you bridge the translator.autocomplete="off", tabindex="-1", aria-hidden="true", and keep the field visually hidden rather than type="hidden" where possible.FormError message before rendering to confirm whether it is a key or translated text. In Symfony, debug:translation helps; in Laravel, verify __('florentin_garnier_spam_protection.invalid') resolves as expected.How can I help you explore Laravel packages today?