• EasySwoole 验证码组件
    • composer 安装
      • 示例:

    EasySwoole 验证码组件

    仓库地址: 验证码组件

    EasySwoole提供了独立的 验证码组件 ,几行代码即可实现输出一个验证码

    composer 安装

    1. composer require easyswoole/verifycode

    示例:

    1. <?php
    2. /**
    3. * Created by PhpStorm.
    4. * User: Apple
    5. * Date: 2018/11/12 0012
    6. * Time: 16:30
    7. */
    8. namespace App\HttpController;
    9. use EasySwoole\Http\AbstractInterface\Controller;
    10. use EasySwoole\VerifyCode\Conf;
    11. class VerifyCode extends Controller
    12. {
    13. function index()
    14. {
    15. $config = new Conf();
    16. $code = new \EasySwoole\VerifyCode\VerifyCode($config);
    17. $this->response()->withHeader('Content-Type','image/png');
    18. $this->response()->write($code->DrawCode()->getImageByte());
    19. }
    20. function getBase64(){
    21. $config = new Conf();
    22. $code = new \EasySwoole\VerifyCode\VerifyCode($config);
    23. $this->response()->write($code->DrawCode()->getImageBase64());
    24. }
    25. }