atendwa / laravel-honeypot
This Laravel package safeguards your forms effortlessly with an invisible shield against spam, featuring seamless integration and configurable settings for optimal protection.
Fund package maintenance!
Atendwa
Requires
- php: ^8.2
- illuminate/contracts: ^10.0||^11.0
- spatie/laravel-package-tools: ^1.16
Requires (Dev)
- larastan/larastan: ^2.9
- laravel/pint: ^1.14
- nunomaduro/collision: ^8.1.1||^7.10.0
- nunomaduro/phpinsights: ^2.11
- orchestra/testbench: ^9.0.0||^8.22.0
- pestphp/pest: ^2.34
- pestphp/pest-plugin-arch: ^2.7
- pestphp/pest-plugin-laravel: ^2.3
- phpstan/extension-installer: ^1.3
- phpstan/phpstan-deprecation-rules: ^1.1
- phpstan/phpstan-phpunit: ^1.3
- spatie/laravel-ray: ^1.35
README
Laravel Honeypot is a package designed to help protect your Laravel applications from spam bots by adding a hidden form field that, when filled, indicates the submission is likely from a bot. It provides a simple and effective method to reduce spam submissions without inconveniencing genuine users.
Installation
You can install the package via composer:
composer require atendwa/laravel-honeypot
Configuration
You can override the default options for the honeypot. First publish the honeypot.php
configuration file:
php artisan vendor:publish --provider="Atendwa\Honeypot\HoneypotServiceProvider" --tag="config"
Add the following variables in your .env file to use you custom configurations
HONEYPOT_ENABLED=TRUE
HONEYPOT_INPUT_NAME=mobile
HONEYPOT_TIME_INPUT_NAME=time_field
HONEYPOT_MINIMUM_SUBMISSION_DURATION=1 #time in seconds
Usage
-
Add the
prevent-spam
middleware to the routes you want to protect from spam bots.Route::post('/submit-comment', [commentController::class, 'store']) ->middleware('prevent-spam');
-
Add the
<x-honeypot::honeypot-fields/>
blade component to the form body<form action="/submit-comment" method="POST"> @csrf <x-honeypot::honeypot-fields/> // other input fields </form>
Testing
composer test
Changelog
Please see CHANGELOG for more information what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security related issues, please email tendwa.am@gmail.com instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.