spatie/laravel-honeypot
Protect Laravel forms from spam bots with a simple honeypot + timed submission check. Add the x-honeypot Blade component (or pass values manually for Inertia) and the package will reject requests with filled honeypot fields or unrealistically fast submits.
honeypot.php for advanced customization.amount_of_seconds (default: 1s) may block legitimate users with slow connections. Requires A/B testing for production tuning.with_csp mandates spatie/laravel-csp, adding complexity if CSP isn’t already implemented.$middleware) risks breaking forms missing <x-honeypot /> unless honeypot_fields_required_for_all_forms is set to false (default).HoneypotData), which may be overlooked during migration.BlankPageResponder) be replaced with custom redirects (e.g., to a "form error" page) to maintain UX consistency?with_csp be enabled, or is inline style injection acceptable?SpamResponder could track blocked attempts.<x-honeypot /> component.UsesSpamProtection trait + HoneypotData.POST /contact).composer require spatie/laravel-honeypot.<x-honeypot /> (set honeypot_fields_required_for_all_forms: true)./spam-error) and adjust amount_of_seconds.honeypot data in HandleInertiaRequests middleware.UsesSpamProtection trait to components and update Blade templates.laravel/framework, spatie/laravel-permission).| Step | Task | Dependencies | Owner |
|---|---|---|---|
| 1 | Install package | - | Backend |
| 2 | Publish config (optional) | Step 1 | Backend |
| 3 | Add <x-honeypot /> to Blade forms |
Step 1 | Frontend |
| 4 | Apply middleware to routes | Step 1 | Backend |
| 5 | Test spam blocking | Steps 1–4 | QA |
| 6 | Integrate Inertia/Livewire | Step 1 | Full-Stack |
| 7 | Customize spam responder | Step 1 | Backend |
| 8 | Monitor false positives | Steps 1–7 | DevOps |
amount_of_seconds and valid_from_timestamp logic.<x-honeypot /> is present in all forms or disable honeypot_fields_required_for_all_forms.laravel-csp is configured if with_csp: true.laravel-debugbar if latency is critical.| Failure Scenario | Impact | Mitigation |
|---|---|---|
| Middleware Fails Open: Spam bypasses protection. | Forms vulnerable to spam. | Use try-catch in middleware or monitor SpamException logs. |
| False Positives: Legitimate users blocked. | UX degradation, support tickets. | Adjust amount_of_seconds; log blocked IPs for review. |
| CSP Conflicts: Inline styles blocked. | Honeypot fields invisible. | Disable with_csp or configure CSP to allow inline styles for honeypot fields. |
| Missing Honeypot Fields: Global middleware rejects valid submissions. | Broken forms. | Set honeypot_fields_required_for_all_forms: false or audit forms pre-rollout. |
<x-honeypot /> to a test form.enabled: false).<x-honeypot /> from formsHow can I help you explore Laravel packages today?