title: Verification code meta:

  • name: description content: EasySwoole verification code component, can be customized to generate QR code graphics or base64 encoding.
  • name: keywords content: swoole|swoole extension|swoole framework|easyswoole|Verification code|Swoole verification code

Verification code generation

VerifyCode.php

VerifyCode verification code operation class, if you do not pass in the Config instance, automatically instantiate a

Calling method:

  1. $config = new Conf();
  2. $code = new \EasySwoole\VerifyCode\VerifyCode($config);
  3. $code->DrawCode();//Generate a verification code and return a Result object

Result.php

The captcha result class, created and returned by the VerifyCode captcha operation class when the DrawCode() method is called

Method list:

  1. /**
  2. * Get captcha image
  3. * @author : evalor <master@evalor.cn>
  4. * @return mixed
  5. */
  6. function getImageByte()
  7. {
  8. return $this->CaptchaByte;
  9. }
  10. /**
  11. * Return image Base64 string
  12. * @author : evalor <master@evalor.cn>
  13. * @return string
  14. */
  15. function getImageBase64()
  16. {
  17. $base64Data = base64_encode($this->CaptchaByte);
  18. $Mime = $this->CaptchaMime;
  19. return "data:{$Mime};base64,{$base64Data}";
  20. }
  21. /**
  22. * Get verification code content
  23. * @author : evalor <master@evalor.cn>
  24. * @return mixed
  25. */
  26. function getImageCode()
  27. {
  28. return $this->CaptchaCode;
  29. }
  30. /**
  31. * Get Mime information
  32. * @author : evalor <master@evalor.cn>
  33. */
  34. function getImageMime()
  35. {
  36. return $this->CaptchaMime;
  37. }
  38. /**
  39. * Get the verification code file path
  40. * @author: eValor < master@evalor.cn >
  41. */
  42. function getImageFile()
  43. {
  44. return $this->CaptchaFile;
  45. }