Download the PHP package osmaviation/recaptcha without Composer
On this page you can find all versions of the php package osmaviation/recaptcha. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download osmaviation/recaptcha
More information about osmaviation/recaptcha
Files in osmaviation/recaptcha
Package recaptcha
Short Description reCAPTCHA Validator for Laravel 5
License MIT
Homepage http://github.com/osmaviation/recaptcha
Informations about the package recaptcha
Recaptcha
A reCAPTCHA Validator for Laravel 5.8 and up.
Installation
Install the package via composer require osmaviation/recaptcha
Setup
If you have auto-discovery enabled the package will register itself.
- If you need to change the default config you can publish it with
php artisan vendor:publish --provider="Greggilbert\Recaptcha\RecaptchaServiceProvider"
. - In your
.env
file, set up your credentials.RECAPTCHA_PUBLIC_KEY
for your public key.RECAPTCHA_PRIVATE_KEY
for your private key.- If you are not using the most recent version of reCAPTCHA, set
RECAPTCHA_VERSION
to 1. - If you are upgrading to v2 of reCAPTCHA, note that your keys from the previous version will not work, and you need to generate a new set in the reCAPTCHA admin.
- The package ships with a default validation message, but if you want to customize it, add the following line into
resources/lang/[lang]/validation.php
:
Usage
v2 (No Captcha)
- In your form, use
{!! Recaptcha::render() !!}
to echo out the markup. - In your validation rules, add the following:
v1 (Legacy)
- In your form, use
{!! Recaptcha::render() !!}
to echo out the markup. - In your validation rules, add the following:
It's also recommended to add required
when validating.
Customization
reCAPTCHA v2 allows for customization of the widget through a number of options, listed at the official documentation. You can configure the output of the captcha through six allowed keys: theme
, type
, lang
, callback
, tabindex
and expired-callback
.
In the config file, you can create an options
array to set the default behavior. For example:
would default the language in all the reCAPTCHAs to Japanese. If you want to further customize, you can pass options through the render option:
Options passed into Recaptcha::render
will always supercede the configuration.
Language
To change the language of the captcha, simply pass in a language as part of the options:
For a list of valid language codes, consulting the official documentation.
Custom template
Alternatively, if you want to set a default template instead of the standard one, you can use the config:
or you can pass it in through the Form option:
v1 customization
For the v1 customization options, consult the old documentation and apply accordingly.
Limitation
Because of Google's way of displaying the reCAPTCHA, this package won't work if you load your form from an AJAX call. If you need to do it, you should use one of the alternate methods provided by Google.