Require this package with composer. It is recommended to only require the package for development.
composer require erfanwmb/captcha
You can change SECURITY_CAPTCHA
in .env
to gd
or recaptcha
or hcaptcha
php artisan vendor:publish --provider="erfanwmb\captcha\CaptchaServiceProvider"
If you don't use auto-discovery, add the ServiceProvider to the providers array in config/app.php
erfanwmb\captcha\CaptchaServiceProvider::class,
If you want to use the facade to log messages, add this to your facades in app.php:
'captcha' => erfanwmb\captcha\CaptchaFacade::class
-
set your recaptcha(google)
SECURITY_RECAPTCHA_SITE_KEY
andSECURITY_RECAPTCHA_SECRET_KEY
for user recaptcha in config.env
-
set your hcaptcha
SECURITY_RECAPTCHA_SITE_KEY
andSECURITY_RECAPTCHA_SECRET_KEY
for user hcaptcha in config.env
-
add flowing code to view to show captcha
@include('captcha.index')
@include('captcha.index',['theme_captcha'=>'light','exclusive_captcha'=>'gd'])
you can use exclusive_captcha
for customize captcha in views
you can use theme_captcha
for customize theme captcha in views
- use this to your request or validation
'g-recaptcha-response'=> [CaptchaFacade::validate($this->exclusive_captcha ?? null)]
you don't need to add required
for validation g-recaptcha-response
- for update, you can use following command for just update views
php artisan vendor:publish --provider="erfanwmb\captcha\CaptchaServiceProvider" --tag="view"
-and if you want to update captcha config you can use following command
this command rewrite all captcha config so recaptcha and hcaptcha (site_key & secret_key) delete
php artisan vendor:publish --provider="erfanwmb\captcha\CaptchaServiceProvider" --tag="config"
if you want to disable captcha temporally use following command
SECURITY_CAPTCHA=null