Skip to content

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.

License

Notifications You must be signed in to change notification settings

nguyendachuy/laravel-recaptcha3

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Google reCAPTCHA v3 in Laravel

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.

Latest Stable Version Total Downloads Latest Unstable Version License

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.

About

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.

Resources

License

Stars

Watchers

Forks

Packages

No packages published