Download the PHP package weijukeji/laravel-apifox-sync without Composer

On this page you can find all versions of the php package weijukeji/laravel-apifox-sync. 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 laravel-apifox-sync

Laravel Apifox Sync

weijukeji/laravel-apifox-sync 是一个 Laravel 扩展包,用于把项目仓库里的 OpenAPI JSON 文档同步到 Apifox。

它解决的问题很直接:接口文档已经在代码仓库中维护,例如 Modules/*/docs/api/*.json,但每次修改后还需要通知并更新 Apifox 远端项目。这个扩展包提供 php artisan apifox:sync 命令,自动查找本地 API JSON 文件,并调用 Apifox OpenAPI 导入接口完成同步。

这个扩展包是做什么的

这个包负责:

这个包不负责:

也就是说,项目仍然需要先按自己的规范维护好 docs/api/*.json,本扩展包只负责把这些 JSON 同步到 Apifox。

适用场景

模块化 Laravel 项目

项目使用 nwidart/laravel-modules 或类似模块化结构,每个模块独立维护 API 文档:

可以按模块同步:

公司内部扩展包或供应商包

默认也会扫描:

适合把内部 Composer 包自带的接口文档一起同步到同一个 Apifox 项目。

AI 辅助开发

当 AI 修改 Laravel 后端接口时,通常会同时修改:

如果只改本地 JSON,不同步 Apifox,团队看到的远端接口文档会继续保持旧版本。这个扩展包就是给 AI 和开发者提供一个固定的同步动作。

在使用 AI 编码助手时,可以在项目的 AGENTS.mdCLAUDE.md 或其他约束文件中写明:

这样 AI 的工作流会变成:

  1. 阅读项目接口规范。
  2. 修改接口实现。
  3. 更新对应 OpenAPI JSON 文档。
  4. 执行 php artisan apifox:sync --module=模块名 或同步指定 JSON 文件。
  5. 在最终回复中说明 Apifox 是否已同步。

这可以减少“代码已改、Apifox 还是旧文档”的问题。

CI 或发布流程

如果团队希望在合并、发布或部署前统一推送 API 文档,可以在 CI 中执行:

建议在 CI 环境中通过密钥管理配置 APIFOX_PROJECT_IDAPIFOX_ACCESS_TOKEN

安装

支持 Laravel 10、11、12、13:

Laravel 会通过 package auto-discovery 自动注册服务提供者。

说明:Laravel 13 的 PHP 版本要求由 Laravel / Illuminate 上游决定;项目安装 Laravel 13 时,请确保运行环境满足 Laravel 13 自身的 PHP 要求。

如需自定义扫描路径或导入选项,可以发布配置文件:

发布后会生成:

环境变量

必须配置:

可选配置:

导入行为相关配置:

默认会覆盖已有接口和 Schema:

如果你的 Apifox 项目需要不同的导入策略,请先确认 Apifox OpenAPI 导入接口支持的选项,再调整这些环境变量。

默认扫描规则

默认配置:

apifox:sync 只会同步路径中包含 docs/api/ 且扩展名为 .json 的文件。类似 Modules/Order/docs/orders.json 这样的文件会被忽略。

使用方法

同步指定文件

也可以一次传多个文件:

按模块同步

多个模块:

命令会根据 module_path_pattern 查找:

同步全部配置文档

命令会扫描 config/apifox.php 中的 paths

仅预览,不发送请求

输出示例:

建议 AI 或开发者在不确定匹配范围时先执行 --dry-run

推荐工作流

开发者手动同步

  1. 修改接口实现。
  2. 修改对应 docs/api/*.json
  3. 执行 dry-run:

  4. 确认文件列表正确后同步:

AI 修改接口时

如果 AI 修改了 Modules/Order/docs/api/*.json,推荐要求 AI 执行:

如果只修改了单个文档:

AI 最终输出中应明确说明:

常见错误

Apifox 配置缺失

错误示例:

解决方式:在 .env 或部署环境中配置:

文件不存在

错误示例:

解决方式:确认路径相对于 Laravel 项目根目录,或者传入绝对路径。

文件路径不受支持

错误示例:

解决方式:把 API 文档放到模块的 docs/api/ 目录下,例如:

JSON 无法解析

错误示例:

解决方式:先修复 JSON 格式,再重新执行同步。

命令摘要

开发与测试

License

MIT


All versions of laravel-apifox-sync with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
illuminate/console Version ^10.0|^11.0|^12.0|^13.0
illuminate/filesystem Version ^10.0|^11.0|^12.0|^13.0
illuminate/http Version ^10.0|^11.0|^12.0|^13.0
illuminate/support Version ^10.0|^11.0|^12.0|^13.0
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 weijukeji/laravel-apifox-sync contains the following files

Loading the files please wait ...