nguyendachuy / laravel-recaptcha3
There is no license information available for the latest version (v1.0.0) of this package.
This library provides support for Google reCAPTCHA v3 in Laravel. This library makes it easy to add reCAPTCHA to your Laravel application to protect against spam and bots.
v1.0.0
2023-12-07 13:22 UTC
Requires
- php: >=7.0.0
- guzzlehttp/guzzle: 6.* || 7.*
This package is auto-updated.
Last update: 2024-11-13 11:22:47 UTC
README
This library provides support for Google reCAPTCHA v3 in Laravel. This library makes it easy to add reCAPTCHA to your Laravel application to protect against spam and bots.
Installation
You can install the package via composer:
composer require nguyendachuy/laravel-recaptcha3
You can publish config file with:
php artisan vendor:publish --tag="recaptcha-config"
This is the contents of the published config file:
return [ /* |-------------------------------------------------------------------------- | The reCAPTCHA site key provided by Google |-------------------------------------------------------------------------- | | Here you can set the sitekey */ 'sitekey' => env('GOOGLE_CAPTCHA_SITEKEY', null), /* |-------------------------------------------------------------------------- | The reCAPTCHA secret key provided by Google |-------------------------------------------------------------------------- | | Here you can set the secet */ 'secret' => env('GOOGLE_CAPTCHA_SECRET', null) ];
References
Google reCAPTCHA documentation: https://developers.google.com/recaptcha/docs/v3
Blade directive
This directive imports the recaptcha JavaScript library and configures it with your site key.
<body> {{-- your app --}} {{-- Default action is "form" --}} @recaptchaJs {{-- or custom action --}} @recaptchaJs('form') </body>
Use on the form
<form> {{-- your input --}} {{-- Default name is "g-recaptcha-response" --}} @recaptchaInput {{-- or custom name --}} @recaptchaInput('custom-name') </form>
Use on the validator
$request->validate([ 'g-recaptcha-response' => 'captcha' ]);
Optimizing Views
php artisan view:clear
Credits
Please feel free to contact me if you find any bug or create an issue for that!.
License
The MIT License (MIT). Please see License File for more information.