xcaro / laravel-recaptcha-api
reCaptcha for Laravel 5
v0.0.1
2021-04-03 08:04 UTC
Requires
- php: ^7.1.3
- guzzlehttp/guzzle: ^6.3
- illuminate/console: ~5.6
- illuminate/contracts: ~5.6
- illuminate/support: ~5.6
Requires (Dev)
- phpunit/phpunit: ^7.0
This package is auto-updated.
Last update: 2024-04-29 04:53:17 UTC
README
Installation
Require this package with composer. It is recommended to only require the package for development.
composer require xcaro/laravel-recaptcha-api
Laravel 5.5+:
Add the ServiceProvider to the providers array in config/app.php:
xcaro\Recaptcha\RecaptchaServiceProvider::class,
and the following to aliases
:
'Recaptcha' => xcaro\Recaptcha\Facades\Recaptcha::class,
Copy the package config to your local config with the publish command
php artisan vendor:publish --provider="xcaro\Recaptcha\RecaptchaServiceProvider"
Add settings reCAPTCHA in your .env
GOOGLE_RECAPTCHA_KEY="${public_key}"
GOOGLE_RECAPTCHA_SECRET="${secret_key}"
Usage
- In your form, use
{!! Recaptcha::render() !!}
to echo out the markup. - In your validation rules, add the following:
$rules = [ // your validation 'g-recaptcha-response' => 'required|recaptcha', // reCaptcha validation ];
Customization
Language
Would default the language in all the reCAPTCHAs to English. If you want to further customize, you can pass options through the render option:
Recaptcha::render([ 'lang' => 'fr' ]);
Options passed into Recaptcha::render
will always supersede the configuration.