Download the PHP package martian/laracaptcha without Composer
On this page you can find all versions of the php package martian/laracaptcha. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download martian/laracaptcha
More information about martian/laracaptcha
Files in martian/laracaptcha
Package laracaptcha
Short Description A Laravel package to seamlessly use hCapthca or reCaptcha on your forms or RESTful APIs
License MIT
Homepage https://github.com/hendurhance/laracaptcha
Informations about the package laracaptcha
LaraCaptcha
A Laravel package to seamlessly integrate Google reCAPTCHA v3, v2 or hCAPTCHA into your application forms or Restful API.
Supported Captcha Services
Service | Version | Type | Supported |
---|---|---|---|
Google reCAPTCHA | v3 | - | ✅ Yes |
Google reCAPTCHA | v2 | Checkbox | ✅ Yes |
Google reCAPTCHA | v2 | Invisible | ✅ Yes |
hCAPTCHA | - | Checkbox | ✅ Yes |
hCAPTCHA | - | Invisible | ✅ Yes |
Installation
Note: This package requires PHP 7.4 or higher.
You can install the package via composer:
Register Service Provider
Add the following to the providers
array in config/app.php
:
Publish Configuration File
Publish the configuration file using the following command:
Configuration
The configuration file is located at config/laracaptcha.php
. The following options are available:
reCAPTCHA v2 Configuration
-
In order to use reCAPTCHA you need to register your site for an API key pair. To use reCaptcha v2 Checkbox, select Challenge (v2) > I'm not a robot Checkbox. To use the invisible reCAPTCHA, select Challenge (v2) > Invisible reCAPTCHA badge. The API key pair consists of a site key and secret key. Set the
default
option torecaptcha
inconfig/laracaptcha.php
: -
Change the
version
option tov2
to use reCAPTCHA v2: - Add
RECAPTCHA_SITE_KEY
andRECAPTCHA_SECRET_KEY
to your.env
file:
reCAPTCHA v3 Configuration
-
In order to use reCAPTCHA you need to register your site for an API key pair. To use reCaptcha v3, select reCAPTCHA v3. The API key pair consists of a site key and secret key. Set the
default
option torecaptcha
inconfig/laracaptcha.php
: -
Change the
version
option tov3
to use reCAPTCHA v3: - Add
RECAPTCHA_SITE_KEY
,RECAPTCHA_SECRET_KEY
andRECAPTCHA_SITE_URL
to your.env
file:
hCAPTCHA Configuration
-
In order to use hCAPTCHA you need to register your site for an API key pair. The API key pair consists of a site key and secret key. Set the
default
option tohcaptcha
inconfig/laracaptcha.php
: - Add
HCAPTCHA_SITE_KEY
andHCAPTCHA_SECRET_KEY
to your.env
file:
These are the test keys we use by default. You should not use them in production!
Usage
To display captcha in your form, follow the steps below according to the captcha configuration you are using.
reCAPTCHA v2 Checkbox & Invisible
Initializing JavaScript
Add the following to the <head>
section of your page:
With other options in Google reCaptcha v2 Checkbox dox
Note: The first parameter is the callback function name, the second is the rendering mode (explicit or onload), and the third is the language code from doc
Displaying Captcha Widget - Checkbox
Add the following to your form:
With other options in Google reCaptcha v2 Checkbox dox
Note: The parameter is an array of attributes for the widget
Displaying Captcha Widget - Invisible
Add the following to your form:
Note: The first parameter is the form identifier, the second is the button label (Submit Button), and the third is an array of attributes for the widget, see doc. Add the formIdentifier value as the id in the form element
Validating Captcha
Add the following to your validation rules:
You can also use the rule in the Validator facade:
Add Custom Validation Message
Add the following to your validation messages:
Or you can change the default message in config/laracaptcha.php
:
reCAPTCHA v3
Initializing JavaScript
Add the following to the <head>
section of your page:
With other options in Google reCaptcha v3 dox
Displaying Captcha Widget
Add the following to your form:
With other options in Google reCaptcha v3 dox
Note: The parameter is an array of attributes for the widget, see doc for actions type
hCAPTCHA v2 Checkbox & Invisible
Initializing JavaScript
Add the following to the <head>
section of your page:
With other options in hCAPTCHA dox
Note: The first parameter is the callback function name, the second is the rendering mode (onload or explicit), the third is the language code from doc, and the fourth is the recaptchacompat option
Displaying Captcha Widget - Checkbox
Add the following to your form:
With other options in hCAPTCHA dox
Note: The parameter is an array of attributes for the widget
Displaying Captcha Widget - Invisible
Add the following to your form, see documentation for invisible hcaptcha:
Note: The first parameter is the form identifier, the second is the button label (Submit Button), and the third is an array of attributes for the widget, see doc
Validating Captcha
Add the following to your validation rules:
You can also use the rule in the Validator facade:
Add Custom Validation Message
Add the following to your validation messages:
Or you can change the default message in config/laracaptcha.php
:
For other configuration go through the config/laracaptcha.php
file.
Testing
Changelog
Please see CHANGELOG for more information what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.