This is where your description should go. Limit it to a paragraph or two. Consider adding a small example.
We invest a lot of resources into creating best in class open source packages. You can support us by buying one of our paid products.
We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on our contact page. We publish all received postcards on our virtual postcard wall.
You can install the package via composer:
composer require shamarkellman/laravel-recaptcha
You can publish the config file with:
php artisan vendor:publish --provider="ShamarKellman\LaravelRecaptcha\LaravelRecaptchaServiceProvider" --tag="laravel-recaptcha-config"
This is the contents of the published config file:
return [
'public_key' => env('GOOGLE_CAPTCHA_PUBLIC_KEY'),
'private_key' => env('GOOGLE_CAPTCHA_PRIVATE_KEY'),
'score_threshold' => 0.5,
];
First of all you have to create your own API keys here
Follow the instructions and at the end of the process you will find Site key and Secret key. Keep them close..you will need soon!
In your .env file you need to set the GOOGLE_CAPTCHA_PUBLIC_KEY and GOOGLE_CAPTCHA_PRIVATE_KEY
GOOGLE_CAPTCHA_PUBLIC_KEY=your_site_key
GOOGLE_CAPTCHA_PRIVATE_KEY=your_site_secret_key
The package contains blade directives and views. You can use either method to add the ReCaptcha to your site.
Method 1 - Blade Directive
- The input directive should be added to your form
<form>
@csrf
@recaptchaInput
... other form feilds
</form>
(optional) you can add the Recaptcha branding your site using @recaptchaBranding
- add the script directive to the bottom just before the end of the body tag
@recaptchaScripts
- Add validation rule in your form request or validation function
use ShamarKellman\LaravelRecaptcha\Rules;
[
//...other rules,
'recaptcha_token' => ['required', new ReCaptchaRule],
];
- You can display the error message
@error('recaptcha_token')
{{ $message }}
@enderror
composer test
Please see CHANGELOG for more information on what has changed recently.
Please see CONTRIBUTING for details.
Please review our security policy on how to report security vulnerabilities.
The MIT License (MIT). Please see License File for more information.