tutorials/recaptcha3
Recaptcha
- Install composer package
composer require tutorials/recaptcha3
- Define service provider in
config/app.php
'providers' => [
...
Tutorials\Recaptcha3\RecaptchaServiceProvider::class
],
- Define variables in
.envfile and put values from recaptcha admin panel
RECAPTCHA_ENABLED=
RECAPTCHA_SITE_KEY=
RECAPTCHA_SECRET_KEY=
- Put
recaptchamiddleware on route
Route::post('/login', LoginController::class)->middleware('recaptcha');
Route::post('/register', LoginController::class)->middleware('recaptcha:0.6');
- Insert
@recaptchablade directive in the layout
<!DOCTYPE html>
<html lang="en">
<head>
<title>Recaptcha</title>
@recaptcha
</head>
</html>
- Wrap your form submit logic with recaptcha validation
window.recaptcha('action_name_for_recaptcha_statistic').then((token) => {
// form submition logic
form.transform((data) => ({
...data,
recaptcha_token: token, // recaptcha_token is required
})).post(route('login'))
});
- Run
php artisan view:clearto clear the view cache
Related Packages
doctrine/dbal
Powerful PHP database abstraction layer (DBAL) with many features for database s...
644,549,754
9,698
laravel/serializable-closure
Laravel Serializable Closure provides an easy and secure way to serialize closur...
423,477,751
607
nunomaduro/collision
Cli error handling for console/command-line PHP applications.
403,217,078
4,664
Version History
| Version | Released | PHP | License |
|---|---|---|---|
| 1.0.2 | ^8.1 | ||
| 1.0.1 | ^8.1 | ||
| 1.0.0 | ^8.1 |