为真则非假 / lumen-captcha
Laravel Lumen Captcha 包
1.0.3
2023-06-20 08:21 UTC
Requires
- php: ^7.2|^8.0
- ext-gd: *
- illuminate/config: ^8|^9
- illuminate/filesystem: ^8|^9
- illuminate/hashing: ^8|^9
- illuminate/support: ^8|^9
- intervention/image: ~2.5
- laravel/lumen-framework: ^8|^9
Suggests
- darkaonline/swagger-lume: For OpenApi docs
- pearl/lumen-request-validate: For request validation
This package is auto-updated.
Last update: 2024-09-20 11:01:10 UTC
README
预览
安装
可以通过Composer安装Captcha Service Provider,需要指定 trueifnotfalse/lumen-captcha
包。
使用Composer要求此包
composer require trueifnotfalse/lumen-captcha
使用 composer update
更新包或使用 composer install
安装。
使用方法
要使用Captcha Service Provider,必须在启动应用程序时注册提供者。有两种基本方法可以实现。
将提供者添加到 bootstrap/app.php
并注册Captcha Service Provider。
$app->register(TrueIfNotFalse\LumenCaptcha\CaptchaServiceProvider::class);
配置
要使用自己的设置,创建配置文件。
config/captcha.php
return [ 'math' => [ 'length' => 5, 'width' => 120, 'height' => 36, 'quality' => 90, 'math' => true, //Enable Math Captcha 'expire' => 60, //Stateless/API captcha expiration ], // ... ];
并在 bootstrap/app.php
中启用它
$app->configure('captcha');
无状态模式
从此URL获取密钥和图片 https:///captcha?config=math
,并使用此方法验证验证码
//key is the one that you got from json response $rules = ['captcha' => 'required|captcha:'. request('key') . ',math'];
返回图片
captcha();
返回 URL
captcha_src();
返回 HTML
captcha_img();
要使用不同的配置
captcha_img('flat'); captcha_img('inverse');
等。