CAPTCHA generation and verification for Switon Framework.
composer require switon/captchaRequirements: PHP 8.3+, Redis by default, and either imagick or gd
use Switon\Captcha\CaptchaInterface;
use Switon\Captcha\CaptchaProof;
use Switon\Core\Attribute\Autowired;
class LoginController
{
#[Autowired] protected CaptchaInterface $captcha;
public function getCaptcha(): array
{
return $this->captcha->create();
}
public function verify(string $key, string $code): void
{
$this->captcha->verify(CaptchaProof::of($key, $code));
}
}Docs: https://docs.switon.dev/latest/captcha
MIT.