tutorials/recaptcha3

Google recaptcha v3 integration for laravel/inertia
6
Install
composer require tutorials/recaptcha3
Latest Version:1.0.2
PHP:^8.1
Last Updated:Jan 21, 2024
Links: GitHub  ·  Packagist
Maintainer: amanukian

Recaptcha

  1. Install composer package
composer require tutorials/recaptcha3
  1. Define service provider in config/app.php
'providers' => [
    ...
    Tutorials\Recaptcha3\RecaptchaServiceProvider::class
],
  1. Define variables in .env file and put values from recaptcha admin panel
RECAPTCHA_ENABLED=
RECAPTCHA_SITE_KEY=
RECAPTCHA_SECRET_KEY=
  1. Put recaptcha middleware on route
Route::post('/login', LoginController::class)->middleware('recaptcha');
Route::post('/register', LoginController::class)->middleware('recaptcha:0.6');
  1. Insert @recaptcha blade directive in the layout
<!DOCTYPE html>
<html lang="en">
    <head>
        <title>Recaptcha</title>
        
        @recaptcha
    </head>
</html>
  1. 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'))
});
  1. Run php artisan view:clear to 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/framework

The Laravel Framework.

598,760,099 34,966
laravel/tinker

Powerful REPL for the Laravel framework.

507,193,856 7,441
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