erfanwmb / captcha
This package is for captcha
Requires
- php: ^8.0
Requires (Dev)
None
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
Installation
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
Copy the package config to your local config with the publish command:
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
Usage
-
set your recaptcha(google)
SECURITY_RECAPTCHA_SITE_KEYandSECURITY_RECAPTCHA_SECRET_KEYfor user recaptcha in config.env -
set your hcaptcha
SECURITY_RECAPTCHA_SITE_KEYandSECURITY_RECAPTCHA_SECRET_KEYfor user hcaptcha in config.env -
add flowing code to view to show captcha
@include('captcha.index')
example
@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)]
warning
you don't need to add required for validation g-recaptcha-response
Update
- 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
warning
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