spatie/laravel-honeypot
Spatie's laravel-honeypot blocks spam form submissions using an invisible honeypot field plus a timestamp check. Just add the x-honeypot Blade component to your form.
Architecture fit
ProtectAgainstSpam HTTP middleware plus a x-honeypot Blade component/directive. It slots into the framework's native extension points (middleware stack, Blade, service provider/config publish) rather than introducing a parallel abstraction or external dependency.valid_from timestamp checked against a minimum fill time. Both are self-contained; no third-party network call, no API key, no client-side JS bundle.Honeypot object for Inertia (Vue/React), a UsesSpamProtection trait + HoneypotData for Livewire, and Volt functional syntax. This matters if our front end is not purely server-rendered.SpamResponder, pluggable SpamProtection class, global enable/disable, and with_csp for CSP nonce compatibility.Integration feasibility
composer require, optional vendor:publish of config/honeypot.php, add one Blade tag per form, and attach the middleware to the submitting route (or append globally / to the web group in bootstrap/app.php for Laravel 11+).enabled) or middleware removal.Technical risk
amount_of_seconds of 1 is aggressive for fast typists and programmatic/assistive input.BlankPageResponder discards the request with no user-facing explanation. Without logging, we lose leads and never know.honeypot_fields_required_for_all_forms and global middleware registration are sharp edges — enabling either without full form coverage will reject legitimate traffic.my_name, valid_from) with real inputs are a documented misconfiguration hazard; randomization mitigates but does not eliminate it.style="display:none", which violates a strict style-src policy unless with_csp is enabled (and spatie/laravel-csp is in place).Key questions
Stack fit
bootstrap/app.php middleware registration as well as legacy Http/Kernel.php. Fits Jetstream/Breeze scaffolds with documented, if somewhat manual, Inertia wiring.Honeypot object must be shared (e.g., in HandleInertiaRequests::share) and the two fields injected into each form's state — this is per-page work, not automatic.Migration path
HONEYPOT_ENABLED=false via env; no data migration to reverse.Compatibility
spatie/laravel-csp integration path; otherwise plan a nonce'd style or a class-based hidden wrapper.HoneypotData property, and a protectAgainstSpam() call inside the submit handler — it is not middleware-enforced there, so it is easy to forget on new components.Sequencing
SpamResponder with logging/redirect) — this determines our observability story.Auth::routes() wrapped in the middleware group, or web group append).honeypot_fields_required_for_all_forms.Maintenance
Support
Scaling
Failure modes
amount_of_seconds, log every block, monitor block-rate by route, alert on spikes, use a soft-fail responder on revenue forms.autocomplete heuristics, test with 1Password/LastPass/Bitwarden.with_csp or supply a nonce.valid_from timestamp inflates the elapsed time (safe direction) but a cached empty form re-served across sessions can behave unexpectedly; verify CDN/page-cache rules.Ramp-up
How can I help you explore Laravel packages today?