Download the PHP package fastknife/ajcaptcha without Composer

On this page you can find all versions of the php package fastknife/ajcaptcha. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package ajcaptcha

AJ-Captcha for PHP

Version PHP License

这个类库使用 PHP 实现了行为验证码(滑动拼图、点选文字)。 v2.0 版本基于 Strategy Pattern(策略模式) 彻底重构了底层架构,移除了第三方图像库依赖,引入了原生 GD 绘图与抗锯齿技术,带来了更极致的体验与更高的性能。

Java实现: https://gitee.com/belief-team/captcha

PHP实现: https://gitee.com/fastknife/aj-captcha

文档地址:https://ajcaptcha.beliefteam.cn/captcha-doc/captchaDoc/html.html

预览效果

block   click

✨ 核心特性 (v2.1)

📸 效果预览

滑动验证码 (Drawing 模式)

(无需任何图片素材,纯代码实时绘制)

效果图占位:建议运行 testImage.php 查看实际效果

点击验证码

支持文字点选,自带干扰文字与随机布局。

🛠 安装

要求

Composer 安装

🚀 快速开始

1. 原生 PHP 使用

2. 框架集成

本库无任何全局变量与单例依赖,完美支持 ThinkPHP, Laravel, Hyperf, Swoole 等现代框架。只需在控制器中实例化 Service 即可。

⚙️ 详细配置说明

src/config.php 中进行配置:

框架缓存集成详解

默认使用的 \Fastknife\Utils\CacheUtils 是一个基于 ThinkPHP 文件缓存改写的轻量级缓存驱动。它会在项目工作目录下自动创建 runtime/cache 目录来存储缓存文件。

1. 方法映射 (适配非 PSR-16 框架)

本库默认期望缓存驱动遵循 PSR-16 规范。如果您的框架缓存方法名不同(例如 ThinkPHP 5.0 使用 rm 而不是 delete),您需要通过 method 配置项进行映射:

2. 常用框架配置示例

Laravel / Lumen:

ThinkPHP 6:

Hyperf:

💻 前端集成注意事项

前端请求时,请确保 Content-Type 设置为 application/x-www-form-urlencoded

Axios 示例:

🏗 架构设计

v2.0 引入了策略模式 (Strategy Pattern),将滑块的生成逻辑解耦。

核心目录结构

绘图原理 (Drawing Mode)

  1. 大画布绘制:系统首先创建一个 6 倍于目标尺寸的透明画布。
  2. 矢量路径:使用 imagefilledpolygon 等函数在画布上绘制高精度的矢量形状(拼图、心形等)。
  3. 光影渲染:在形状内部绘制半透明的内阴影、外发光,模拟立体感。
  4. 高斯模糊:应用轻微的高斯模糊 (IMG_FILTER_GAUSSIAN_BLUR) 柔化边缘。
  5. 下采样:使用 imagecopyresampled 将大图缩放回原尺寸,生成高质量的 Alpha Mask。
  6. 混合渲染:利用 Alpha Blending 将 Mask 与背景图混合,实现完美的抠图效果。

🧪 开发环境快速启动

在本仓库中已内置 test/ 目录作为本地联调与演示入口,使用 PHP 内置开发服务器即可快速启动。

准备

启动服务

本地接口说明

test/ 目录已提供最小后端接口,前端 index.html 的交互将直接请求这些接口:

对应控制器实现可参考:

调试配置

开发时可直接修改 src/config.php 来观察不同效果:

常见问题

📝 变更日志

查看 CHANGELOG.md

🤝 贡献

欢迎提交 Issue 和 Pull Request!如果你想添加新的滑块形状,只需实现 ShapeDrawerInterface 并在 ShapeFactory 中注册即可。

📄 License

MIT


All versions of ajcaptcha with dependencies

PHP Build Version
Package Version
Requires php Version >=7.1
ext-gd Version *
ext-openssl Version *
ext-iconv Version *
ext-json Version *
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package fastknife/ajcaptcha contains the following files

Loading the files please wait ...