Laravel Captcha
Laravel Captcha is a wrapper around HCaptcha & Google Recaptcha. It provides very easy-to-use Facade, Validation Rule, and blade directives.
Installation
Requires PHP 7.3+
- Install via Composer:
composer require rahul900day/laravel-captcha
- Publish the config file with:
php artisan vendor:publish --tag="captcha-config"
- Add required configuration to
.env
file:
CAPTCHA_DRIVER=hCaptcha
CAPTCHA_SITE_KEY="{Your Site Key}"
CAPTCHA_SECRET_KEY="{Your Site Secret}"
Don't know how to get the Site Key or Site Secret ?
Read HCaptcha or ReCaptcha Docs.
Configuration
Laravel Captcha supports very different customizations like theme, language, size. Just add these configurations to your .env
file to customize.
Supported ENV Variables
Variable | Default | Description |
---|---|---|
CAPTCHA_DRIVER | hCaptcha |
Default Captcha driver Supported: hCaptcha , reCaptcha |
CAPTCHA_SITE_KEY | '' |
The Site Key. HCaptcha Docs: https://docs.hcaptcha.com/configuration ReCaptcha Docs: https://developers.google.com/recaptcha/docs/display |
CAPTCHA_SECRET_KEY | '' |
The Site Secret. HCaptcha Docs: https://docs.hcaptcha.com/configuration ReCaptcha Docs: https://developers.google.com/recaptcha/docs/display |
CAPTCHA_LOCALE | en |
The Captcha localization code. HCaptcha Supported Codes: https://docs.hcaptcha.com/languages Recaptcha Supported Codes: https://developers.google.com/recaptcha/docs/language |
CAPTCHA_THEME | light |
The Captcha checkbox theme. Supported: light , dark |
CAPTCHA_SIZE | normal |
The Captcha checkbox size. Supported: normal , compact |
Note: Laravel Captcha Does not support ReCaptcha V3
Usage
Displaying Captcha
Laravel Captcha Provide two blade directives for importing required javascript and displaying the captcha itself.