php-captcha/captcha

php image captcha

1.0 2017-03-22 08:18 UTC

This package is not auto-updated.

Last update: 2025-05-02 23:20:06 UTC


README

php image captcha , need GD extension.

require

Predis

install

composer.json

require: {
    "php-captcha/captcha": "~1.0"
}

example

  • use base64 string

      use Captcha\CaptchaManager
      
      $redisClient = ...;
      $identity = ...;
      
      $captcha = new CaptchaManager($redisClient);
      
      $base64ImageString = $captcha->createBase64ImageCaptcha($identity);
      
      $response = ...;
      
      $response->setBody($base64ImageString);
      
      return $response;
    
  • use content-type:image/png

      use Captcha\CaptchaManager
      
      $redisClient = ...;
      $identity = ...;
      
      $captcha = new CaptchaManager($redisClient);
      
      $captcha->createStreamImageCaptcha($identity);
      
      $response = ...;
      
      $response->headers->add([Content-type' => 'image/png']);
      
      return $response;