switon/captcha

Sessionless image CAPTCHA challenges with shared-store verification for Switon Framework

Maintainers

Package info

github.com/switon-php/captcha

Documentation

pkg:composer/switon/captcha

Statistics

Installs: 0

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v1.0.0 2026-06-06 13:43 UTC

This package is auto-updated.

Last update: 2026-06-07 05:06:51 UTC


README

CI PHP 8.3+

Switon's CAPTCHA challenge, proof, and action-guard layer.

Highlights

  • Challenge and verification flow: generate a CAPTCHA, then verify the returned proof.
  • Standard request fields: CaptchaProofResolver reads the usual CAPTCHA key and code fields.
  • Protected actions: #[CaptchaRequired] blocks an action until proof is valid.
  • Image backends: the package includes GD and Imagick adapters for image generation.
  • Observable checks: creation, verification, and failure activity can be observed.

Installation

composer require switon/captcha

Quick Start

use Switon\Captcha\CaptchaInterface;
use Switon\Captcha\Attribute\CaptchaRequired;
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 verifyAction(CaptchaProof $proof): void
    {
        $this->captcha->verify($proof);
    }

    #[CaptchaRequired]
    public function submitAction(): void
    {
    }
}

Docs: https://docs.switon.dev/latest/captcha

License

MIT.