poolbang / captcha
captcha for swoft
Installs: 5
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Type:package
Requires
- php: ^7.2
- ext-imagick: *
- swoft/stdlib: ~2.0.0
This package is auto-updated.
Last update: 2025-03-16 12:34:40 UTC
README
Installation
composer require poolbang/captcha
Configuration
To use your own settings, create captcha config.
config/captcha.php
return [ 'default' => [ 'length' => 5, 'width' => 120, 'height' => 36, 'quality' => 90, 'math' => true, //Enable Math Captcha ], // ... ];
Example Usage
/** * @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 }
Based on Intervention Image