Google reCAPTCHA Validator Package for Laravel Framework
vinkas/laravel-recaptcha is a Laravel package for google recaptcha validator package for laravel framework.
It currently has 1 GitHub stars and 472 downloads on Packagist (latest version v1.0.1).
Install it with composer require vinkas/laravel-recaptcha.
Discover more Laravel packages by vinkas
or browse all Laravel packages to compare alternatives.
Last updated
You may install by running the composer require command in your terminal:
composer require vinkas/laravel-recaptcha
Add Service Provider to your config/app.php file
Vinkas\Laravel\Recaptcha\ServiceProvider::class,
And run php artisan command to publish package config file
php artisan vendor:publish --provider="Vinkas\Laravel\Recaptcha\ServiceProvider"
Add your recaptcha site key and secret in .env file
RECAPTCHA_SITE_KEY=__________
RECAPTCHA_SECRET=__________
Add recaptcha custom error message in resources\lang\en\validation.php file
'recaptcha' => 'The capcha verfication failed. Please try again.',
Add recaptcha field in your form's blade view
<div class="g-recaptcha" data-sitekey="{{ getenv('RECAPTCHA_SITE_KEY') }}"></div>
@if ($errors->has('g-recaptcha-response'))
{{ $errors->first('g-recaptcha-response') }}
@endif
Add Validator calling function in your app controller file
Validator::make($data, [
'g-recaptcha-response' => 'required|recaptcha',
]);
It's done! Now your form spam protected by Google reCAPTCHA!!!