Download the PHP package wiseadmin/wise-api without Composer

On this page you can find all versions of the php package wiseadmin/wise-api. 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 wise-api

wiseadmin/wise-api

为 ThinkPHP 6.0+ 或 8.0+ 提供的 API 快速开发工具包——开箱即用的限流、签名、JWT 鉴权、统一响应、字段过滤与分页包装、Debug 模式调试面板。

PHP ThinkPHP Packagist


特性

模块 说明
API 版本管理 通过 URL 前缀 api/v1、api/v2 自动路由到不同子命名空间
接口限流 令牌桶 + 滑动窗口双算法,原生 Redis Lua 脚本保证原子性
签名验证 HMAC-SHA256,支持时间戳防重放 + Nonce 防重放
JWT 鉴权 纯 PHP 实现 HS256/RS256,零外部依赖,支持自动续签
统一响应 {code, msg, data, timestamp} 结构,错误码枚举
字段过滤 ?fields=id,name + allowFields() 显式过滤
统一分页 {list, total, page, page_size} 自动包装
调试面板 Debug 模式下记录耗时、内存、限流状态、JWT、签名过程、SQL 日志

安装

包通过 composer.json 的 extra.think.services 自动注册服务提供者,无需手动配置。


配置

将 vendor/wiseadmin/wise-api/config/wise-api.php 复制到项目 config/ 目录后按需修改:


基础用法

1. 控制器继承 ApiController

2. 路由(API 版本管理)

业务请求 /api/v1/users 自动路由到 app\api\controller\v1\UserController。 增加 /api/v2/users 只需新建 app\api\controller\v2\UserController + app/api/route/v2.php。

3. JWT 签发与解析

4. 在控制器获取当前登录用户

5. 手动签名(供业务方主动签名时复用)

6. 限流分组

匹配到分组时,相应 API 自动使用分组配置;未匹配时使用 default。

7. 自动续签

JwtAuthMiddleware 在剩余有效期 < refresh_ttl 时,会在响应头自动添加:

客户端在 axios/fetch 拦截器中替换本地 token 即可。


调试面板(仅 Debug 模式)

启动应用时调用 app()->isDebug() 必须为 true。启用后:

生产环境 app()->isDebug() 为 false 时,/__debug_api 路由自动不注册。


架构概览


错误码

Code HTTP 含义
0 200 成功
1000 500 未知错误
1001 400 参数无效
2000 401 未鉴权
2001 401 Token 无效
2002 401 Token 过期
2100 400 签名错误
2101 400 时间戳超出容差
2102 400 Nonce 重复
2200 403 无权限
3000 429 触发限流
4001 404 数据不存在
4002 409 数据冲突
9000 502 上游错误

License

MIT


All versions of wise-api with dependencies

PHP Build Version
Package Version
Requires php Version >=8.1
topthink/framework Version ^8.0
psr/log Version ^1.1 || ^2.0 || ^3.0
wiseadmin/wise-jwt Version 1.0.*
wiseadmin/wise-support Version 1.0.*
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 wiseadmin/wise-api contains the following files

Loading the files please wait ...