Configuration
Publish package
Create config/recaptcha.php
configuration file using the following artisan command:
$ php artisan vendor:publish --provider="Biscolab\ReCaptcha\ReCaptchaServiceProvider"
Set the environment
Add your API Keys
Open .env
file and set RECAPTCHA_SITE_KEY
and RECAPTCHA_SECRET_KEY
:
# in your .env file
RECAPTCHA_SITE_KEY=YOUR_API_SITE_KEY
RECAPTCHA_SECRET_KEY=YOUR_API_SECRET_KEY
Complete configuration
Open config/recaptcha.php
configuration file and set version
:
return [
'api_site_key' => env('RECAPTCHA_SITE_KEY', ''),
'api_secret_key' => env('RECAPTCHA_SECRET_KEY', ''),
'version' => 'v2', // supported: v3|v2|invisible
'skip_ip' => [], // array of IP addresses - String: dotted quad format e.g.: 127.0.0.1
'default_validation_route' => env('RECAPTCHA_DEFAULT_VALIDATION_ROUTE', 'biscolab-recaptcha/validate'),
'default_token_parameter_name' => env('RECAPTCHA_DEFAULT_TOKEN_PARAMETER_NAME', 'token')
];
api_site_key
and `api_secret_key are reCAPTCHA keys you have to create in order to perform Google API authentication. For more information about Site Key and Secret Key please visit Google reCAPTCHA developer documentationversion
indicates the reCAPTCHA version (supported: v3|v2|invisible). Get more info about reCAPTCHA version at https://developers.google.com/recaptcha/docs/versions.skip_ip
is a whitelist of IP addresses that, if recognized, disable the reCAPTCHA validation (return always true) and if you embed JS code in blade (view) file NO validation call will be performed.default_validation_route
is the route called via javascript built-in validation script (v3 only)default_token_parameter_name
is the name of "token" GET parameter sent todefault_validation_route
to be validated (v3 only)
Reload config cache file
!!! IMPORTANT !!! Every time you change some configuration run the following shell command:
$ php artisan config:cache
Have you updated?
If you are migrating from an older version add skip_ip
array in recaptcha.php
configuration file.
Customize error message
Just for v2 and invisible users.
Before starting please add the validation message to resources/lang/[LANG]/validation.php
file
return [
...
'recaptcha' => 'Hey!!! :attribute is wrong!',
];