spatie/laravel-honeypot
Protect Laravel forms from spam using a honeypot field plus a minimum-time check. Add the Blade component (or pass values manually for Inertia) and suspicious submissions are automatically discarded.
<x-honeypot /> or @honeypot).ProtectAgainstSpam) to routes/controllers.<1s) may block legitimate users with slow connections. Mitigated via configurable amount_of_seconds.with_csp is enabled alongside laravel-csp.app/Http/Kernel.php) risks breaking forms without honeypot fields unless honeypot_fields_required_for_all_forms is disabled.laravel-csp already in use? If not, evaluate CSP integration effort.UsesSpamProtection trait and HoneypotData property binding.guessHoneypotDataProperty.SpamException).ProtectAgainstSpam to $middleware in Kernel.php after validating no regressions.composer require spatie/laravel-honeypot:^2.0.$request before honeypot validation (e.g., CSRF middleware runs after by default).composer require spatie/laravel-honeypot
php artisan vendor:publish --provider="Spatie\Honeypot\HoneypotServiceProvider" --tag="honeypot-config"
honeypot.php for field names, timestamp thresholds, and spam responses.laravel-csp.<x-honeypot /> to Blade forms.ProtectAgainstSpam to routes or globally.amount_of_seconds).SpamResponder to log blocked attempts for analytics (e.g., IP geolocation, user agent patterns).valid_from_timestamp and network latency.console.log(honeypot)).| Failure Scenario | Impact | Mitigation |
|---|---|---|
| Middleware misconfiguration | Legitimate forms blocked | Test with honeypot_fields_required_for_all_forms = false. |
| CSP conflicts | Honeypot fields invisible | Enable with_csp and configure laravel-csp. |
| Timestamp validation too strict | High false-positive rate | Increase amount_of_seconds (e.g., to 3s). |
| Inertia/Livewire field injection | Frontend errors | Validate honeypot object in component props. |
| Spam responder fails | 500 errors | Implement fallback responder (e.g., AbortResponder). |
<x-honeypot /> + middleware).How can I help you explore Laravel packages today?