huangdijia/laravel-recaptcha-v3
recaptcha-v3 for laravel
11,692
19
| Install | |
|---|---|
composer require huangdijia/laravel-recaptcha-v3 |
|
| Latest Version: | v2.1.0 |
| PHP: | >=8.0 |
| License: | MIT |
| Last Updated: | Mar 8, 2024 |
| Links: | GitHub · Packagist |
Maintainer: huangdijia
Google reCaptcha v3 for Laravel 5.6+
Installation
To install, simply add it
to your composer.json file:
{
"require": {
"huangdijia/laravel-recaptcha-v3": "^3.0"
}
}
And run composer to update your dependencies:
composer update
Or you can simply run
composer require huangdijia/laravel-recaptcha-v3
Publish configuration file to your config folder with command:
php artisan vendor:publish --provider="Huangdijia\Recaptcha\RecaptchaServiceProvider" --tag=config
Usage
Forms
// default
@recaptcha_field()
// custom
@recaptcha_field(['site_key'=>'your_key', 'name'=>'input_name'])
Init Recaptcha Javascript
Must add after @recaptcha_field()
Recaptcha v3 works best when it is loaded on every page to get the most context about interactions. Therefore, add to your header or footer template:
// default
@recaptcha_initjs()
// custom
@recaptcha_initjs(['site_key'=>'your_key', 'action' => 'action_name', 'name'=>'input_name'])
Validation as regular validation rule
Use as regular validation rule recaptcha:{ACTION},{SCORE},{HOSTNAME} like:
Validator::make($request->all(), [
'g-recaptcha-response' => 'required|recaptcha:register,0.5,www.a.com',
// or
// 'g-recaptcha-response' => 'required|recaptcha',
]);
Validation as middleware
Set $routeMiddleware
$routeMiddleware = [
// ...
'recaptcha' => Huangdijia\Recaptcha\Middleware\ReCaptcha::class,
];
Use with route
Route::get('/path')->middleware('recaptcha');
Route::get('/path')->middleware('recaptcha:{ACTION},{SCORE},{HOSTNAME}');
Hidden ReCAPTCHA
.grecaptcha-badge {
display: none;
}
Related Packages
martian/laracaptcha
A Laravel package to seamlessly use hCapthca or reCaptcha on your forms or RESTf...
1,022
14
doctrine/dbal
Powerful PHP database abstraction layer (DBAL) with many features for database s...
637,827,751
9,703
laravel/serializable-closure
Laravel Serializable Closure provides an easy and secure way to serialize closur...
413,412,504
609
Version History
| Version | Released | PHP | Laravel | License |
|---|---|---|---|---|
| v2.1.0 | >=8.0 | ^9.0| | MIT | |
| 2.0.0 | >=8.0 | ^9.0 | MIT | |
| 1.3.0 | >=7.0.0 | ^5.7| | MIT | |
| 1.2.4 | >=7.0.0 | ^5.7| | MIT | |
| 1.2.3 | >=7.0.0 | ^5.7| | MIT | |
| 1.2.2 | >=7.0.0 | ^5.7| | MIT | |
| 1.2.1 | >=7.0.0 | ^5.7| | MIT | |
| 1.2.0 | >=7.0.0 | ^5.7| | MIT | |
| 1.1.4 | >=7.0.0 | ^5.5| | MIT | |
| 1.1.3 | >=7.0.0 | ~5.5.0| | MIT | |
| 1.1.2 | >=7.0.0 | ~5.5.0| | MIT | |
| 1.1.1 | >=7.0.0 | ~5.5.0| | MIT | |
| 1.1.0 | >=7.0.0 | ~5.5.0| | MIT | |
| 1.0.14 | >=7.0.0 | ~5.5.0| | MIT | |
| 1.0.13 | >=7.0.0 | ~5.5.0| | MIT | |
| 1.0.12 | >=7.0.0 | 5.0.*| | MIT | |
| 1.0.11 | >=7.0.0 | 5.0.*| | MIT | |
| 1.0.10 | >=7.0.0 | 5.0.*| | MIT | |
| 1.0.9 | >=7.0.0 | 5.0.*| | MIT | |
| 1.0.8 | >=7.0.0 | 5.0.*| | MIT | |
| 1.0.7 | >=7.0.0 | 5.0.*| | MIT | |
| 1.0.6 | >=7.0.0 | 5.0.*| | MIT | |
| 1.0.5 | >=7.0.0 | 5.0.*| | MIT | |
| 1.0.4 | >=7.0.0 | 5.0.*| | MIT | |
| 1.0.3 | >=7.0.0 | 5.0.*| | MIT | |
| 1.0.2 | >=7.0.0 | 5.0.*| | MIT | |
| 1.0.1 | >=7.0.0 | 5.0.*| | MIT | |
| 1.0.0 | >=7.0.0 | 5.0.*| | MIT |
Pre-releases (2)
| Version | Released | PHP | Laravel | License |
|---|---|---|---|---|
| v3.0.0-beta.1 | >=8.0 | ^9.0| | MIT | |
| 2.0.0-beta | >=7.3.0 | ^8.0| | MIT |

