poolbang / captcha
为swoft提供的验证码
v1.0.1
2019-10-16 00:00 UTC
Requires
- php: ^7.2
- ext-imagick: *
- swoft/stdlib: ~2.0.0
This package is auto-updated.
Last update: 2024-09-16 11:26:34 UTC
README
安装
composer require poolbang/captcha
配置
要使用自己的设置,请创建验证码配置文件。
config/captcha.php
return [ 'default' => [ 'length' => 5, 'width' => 120, 'height' => 36, 'quality' => 90, 'math' => true, //Enable Math Captcha ], // ... ];
示例用法
/** * @RequestMapping(route="captcha") * @return \Swoft\Http\Message\Response|static */ public function image(){ $captcha = Captcha::create(); echo $captcha->getKey().PHP_EOL; // generate captcha code return context()->getResponse()->withContent($captcha->getImage()->encode($captcha->getImage()->extension, 90)->encoded)->withContentType($captcha->getImage()->mime()); // show captcha image }