hirenkeraliya / lara-captcha
Laravel custom recaptcha.
Requires
- php: ^8.1
- illuminate/support: ^9.0
This package is auto-updated.
Last update: 2024-05-14 18:16:03 UTC
README
Laravel Captcha (Laravel 9.x)
Lara-Captcha is a reliable and easy-to-use package for preventing bot submissions and enhancing the security of public forms in Laravel. With its simple integration and multiple customization options, it's a great choice for developers looking to improve the safety of their forms.
Requirements
PHP | Laravel | Package |
---|---|---|
8.1+ | 9.x | v1.0.0 |
Features
- Easy integration with Laravel forms
- Supports multiple configurations for customization
- Provides effective protection against bot submissions
- Minimal code changes required for implementation
- Regular updates and bug fixes from the author
- Lightweight package for efficient performance
Usage
Here's an example of how to use Lara-Captcha in your Laravel form:
<form method="POST" action="/submit-form"> @csrf @captcha <input type="text" name="name" placeholder="Name"><br> <input type="email" name="email" placeholder="Email"><br> <button type="submit">Submit</button> </form>
Installation
Follow these steps to install the package:
- Run the following command in your terminal/cmd:
composer require hirenkeraliya/lara-captcha
- Import the configuration file by running this command in your terminal/cmd:
php artisan vendor:publish --tag=lara-captcha-config
-
Add
@captcha
in your form after the CSRF token. -
To use the middleware, add the following line to your route:
use Hirenkeraliya\LaraCaptcha\app\Http\Middleware\VerifyCaptcha; Route::post('contact-us', [ContactUsController::class, 'index'])->name('front.contact_us')->middleware(VerifyCaptcha::class);
or You can apply it to multiple routes by utilizing route grouping.
use Hirenkeraliya\LaraCaptcha\app\Http\Middleware\VerifyCaptcha; Route::group(['middleware' => VerifyCaptcha::class], function () { Route::post('contact-us', [ContactUsController::class, 'index'])->name('front.contact_us'); }); Route::middleware([VerifyCaptcha::class])->group(function () { Route::post('contact-us', [ContactUsController::class, 'index'])->name('front.contact_us'); });
That's it! Your form is now secured against bot submissions.
Configuration
Lara-Captcha provides multiple configuration options that you can modify to fit your needs. The default configuration can be found in the config/lara-captcha.php
file after running the vendor:publish command.
You can modify the following configuration options:
enabled
: The validation can be enabled or disabled.input_name
: The name of the input field in your form.error.message
: The error message to display when a bot submission is detected.error.status_code
: The error status code to display when a bot submission is detected.
Authors
- Hiren Keraliya - Initial work
Support
If you encounter any issues with Lara-Captcha or have suggestions for improvement, feel free to open an issue on the GitHub repository.
Contributing
Contributions to Lara-Captcha are always welcome! To contribute, simply fork the repository, make your changes, and submit a pull request.
License
This project is licensed under the MIT License - see the LICENSE file for details
Special Thanks to
Special thanks to the Laravel community for their support