{"id":37013523,"url":"https://github.com/liujiawm/think-captcha","last_synced_at":"2026-01-14T01:19:32.830Z","repository":{"id":57040924,"uuid":"323110429","full_name":"liujiawm/think-captcha","owner":"liujiawm","description":"thinkphp6图片验证码","archived":false,"fork":false,"pushed_at":"2021-11-01T08:14:40.000Z","size":751,"stargazers_count":7,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-09-18T18:41:46.702Z","etag":null,"topics":["base64","captcha","png","think-captcha","thinkcaptcha","thinkphp"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/liujiawm.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-12-20T16:03:16.000Z","updated_at":"2023-05-08T13:06:48.000Z","dependencies_parsed_at":"2022-08-24T01:10:38.215Z","dependency_job_id":null,"html_url":"https://github.com/liujiawm/think-captcha","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/liujiawm/think-captcha","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/liujiawm%2Fthink-captcha","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/liujiawm%2Fthink-captcha/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/liujiawm%2Fthink-captcha/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/liujiawm%2Fthink-captcha/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/liujiawm","download_url":"https://codeload.github.com/liujiawm/think-captcha/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/liujiawm%2Fthink-captcha/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28407670,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T00:40:43.272Z","status":"ssl_error","status_checked_at":"2026-01-14T00:40:42.636Z","response_time":56,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["base64","captcha","png","think-captcha","thinkcaptcha","thinkphp"],"created_at":"2026-01-14T01:19:32.278Z","updated_at":"2026-01-14T01:19:32.820Z","avatar_url":"https://github.com/liujiawm.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# thinkcaptcha\nthinkphp6图片验证码\n\n[https://liujiawm.github.io/](https://liujiawm.github.io/)\n\n## 安装\nphp版本要求 \u003e=7.1.0\n\ncomposer\n```\ncomposer require phpu/think-captcha\n```\n如果项目未开启SESSION,则需要开启，开启方式参考[thinkphp6完全开发手册中杂项之SESSION](https://www.kancloud.cn/manual/thinkphp6_0/1037635)\n\n## require\n- mbstring\n- gd\n- topthink/framework ^6.0.0\n\n### 注意：验证码不支持多字节字符\n\n![](https://images.gitee.com/uploads/images/2021/0105/011626_7d5bbaca_1247621.png)\n\n![](https://images.gitee.com/uploads/images/2021/0105/011636_1c8e7f1d_1247621.png)\n\n![](https://github.com/liujiawm/think-captcha/raw/main/test1.png)\n\n![](https://github.com/liujiawm/think-captcha/raw/main/test2.png)\n## 使用方法\n\n控制器文件use phpu\\facade\\ThinkCaptcha;\n\n```\nuse phpu\\facade\\ThinkCaptcha;\n```\n\n### 输出验证码图片\n\n验证码显示控制器\n```\n    public function captcha(){\n        return ThinkCaptcha::printImg(); // png图片\n        // return ThinkCaptcha::printBase64(); // Base64\n    }\n```\n### 验证\n\n验证码验证控制器\n```\n    public function check($code){\n    \n        if (false === ThinkCaptcha::check($code)){\n            return response('验证码输入错误',200);\n        }else{\n            return response('验证码输入正确',200);\n        }\n    \n    }\n```\n## 更多说明\n\n如果创建验证码时使用独立的key\n\n`\nThinkCaptcha::printImg('test') // 'test'是识别key,限数字和字母\n`\n\n那么验证时也需要传入同名key\n\n`\nThinkCaptcha::check($code,'test') // 'test'是识别key,限数字和字母\n`\n\n默认验证完后不论成功还是错误都会删除验证码数据，如果验证完后不删除\n\n`\nThinkCaptcha::check($code,'test',0) // 0表示不删除\n`\n\n或者，只有在验证成功后才删除\n\n`\nThinkCaptcha::check($code,'test',1) // 1表示验证成功后才删除\n`\n\n当然，验证时也可以设置验证码过期时间，默认1800秒(30分钟内有效)\n\n`\nThinkCaptcha::check($code,'test',2,3600) // 1小时内有效\n`\n\n## 独立配置\n\n配置文件中提供独立配置，\n\n如果无效果建议将配置文件config.php改名为`phpu_captcha.php`移入项目配置目录内！\n\n使用`configure()`配置，参数是配置文件一级数组的索引，默认为`default`\n\n例：\n\n```\n/**\n * 配置文件中提供独立配置，\n * 如果无效果建议将配置文件config.php改名为phpu_captcha.php移入项目配置目录内！\n */\n    public function captcha(){\n        return ThinkCaptcha::configure('sign')-\u003eprintImg();\n    }\n\n```\n\n配置文件\n\n```\n     return [\n         // 默认配置\n         'default' =\u003e [\n             'char_preset' =\u003e '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ', // 预设字符集，不支持多字节字符\n             'length'     =\u003e 5, // 验证码位数\n             'width'      =\u003e 0, // 图片宽\n             'height'     =\u003e 0, // 图片高\n             'font_size'   =\u003e 48, // 验证码字体大小(px)\n             'bg'         =\u003e [243, 251, 254], // 背景颜色\n             'use_curve'   =\u003e true, // 是否画混淆曲线\n             'use_noise'   =\u003e true, // 是否添加杂点\n             'use_img_bg'   =\u003e true, // 是否使用背景图片\n         ],\n     \n         // 独立配置\n         'sign' =\u003e [\n             'char_preset' =\u003e '0123456789', // 预设字符集\n             'length'     =\u003e 4, // 验证码位数\n             'width'      =\u003e 100, // 图片宽\n             'height'     =\u003e 36, // 图片高\n             'font_size'   =\u003e 24, // 验证码字体大小(px)\n             'use_img_bg'   =\u003e false, // 是否使用背景图片\n         ],\n     ];\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fliujiawm%2Fthink-captcha","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fliujiawm%2Fthink-captcha","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fliujiawm%2Fthink-captcha/lists"}