Download the PHP package kode/express-api without Composer

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

kode/express-api

通用快递API集成包,支持多种快递公司接口,提供统一的调用方式,便于快速集成到各种PHP项目中。

功能特性

安装

使用Composer安装:

配置说明

获取API密钥

要使用各快递公司API,您需要在相应开放平台注册并获取API密钥:

  1. EMS

    • 访问EMS开放平台
    • 注册开发者账号并完成企业认证
    • 在API控制台选择需要的服务接口
    • 获取API密钥(AppKey和AppSecret)
  2. 顺丰SF

    • 访问顺丰开放平台
    • 注册开发者账号并申请API权限
    • 获取API密钥
  3. 韵达

    • 访问韵达开放平台
    • 注册开发者账号并完成认证
    • 获取API密钥
  4. 中通

    • 访问中通开放平台
    • 注册开发者账号并完成认证
    • 获取API密钥
  5. 申通

    • 访问申通开放平台
    • 注册开发者账号并完成认证
    • 获取API密钥
  6. 菜鸟网络
    • 访问菜鸟开放平台
    • 注册开发者账号并完成认证
    • 获取AppKey、AppSecret和PartnerId

环境配置

生产环境

在生产环境中使用真实的EMS API端点:

沙箱环境

在开发和测试阶段,建议使用沙箱环境:

配置参数详解

app_key

app_secret

partner_id

sandbox

timeout

version

认证机制

EMS API使用OAuth 2.0客户端凭证模式进行认证:

  1. 使用app_keyapp_secret获取访问令牌
  2. 在后续API请求中使用该令牌进行认证

网络要求

生产环境端点

沙箱环境端点

确保您的服务器能够访问这些地址。

快速开始

初始化API客户端

API方法

1. 发货通知

2. 批量发货

3. 取件通知

4. 订单查询

5. 批量查询订单

6. 取消订单

7. 轨迹查询

8. 批量轨迹查询

9. 拦截件

10. 改件信息

11. 面单打印

12. 批量面单打印

面单布局功能设计

功能概述

面单布局功能用于生成和管理快递面单的打印布局配置,支持不同快递公司的面单模板。

面单模板结构

布局管理器

获取和使用字段值

核心类设计

LayoutManager

负责面单布局的管理,包括创建、读取、更新、删除模板。

Template

表示一个面单模板,包含尺寸信息和字段定义。

使用面单可视化编辑器

  1. 启动PHP内置服务器:

  2. 访问 http://localhost:8000/ 进入面单可视化编辑器

  3. 使用编辑器功能:
    • 拖拽调整元素位置
    • 调整元素大小
    • 修改元素属性(字体、颜色、边框等)
    • 添加文本、条形码、二维码元素
    • 选择面单规格
    • 预览和导出配置

面单模板配置示例

多语言支持

AdvancedLayoutManager 支持创建和管理多语言字段,使得面单模板可以在不同语言环境下使用。

MultilingualField 类

MultilingualField 类继承自 Field 类,提供了多语言标签的支持。

构造函数

配置参数

方法

使用示例

在模板中使用多语言字段

在创建模板时,可以通过在字段配置中添加 labels 参数来创建多语言字段:

错误处理

所有API调用返回的响应都遵循统一的格式:

开发指南

集成新的快递公司

  1. 创建新的配置类(继承AbstractConfig)
  2. 创建认证类(实现AuthInterface)
  3. 创建客户端类(实现ClientInterface)
  4. 更新ExpressApiClient.php,添加新的快递公司支持
  5. 在ResponseHandler.php中添加新的响应处理逻辑

代码规范

本项目遵循PSR-12代码规范。

代码检查

使用PHP_CodeSniffer检查代码规范:

自动修复

自动修复代码规范问题:

运行测试

运行所有测试用例:

测试覆盖率

生成测试覆盖率报告:

测试要求

  1. 测试覆盖率: 所有代码都必须有相应的测试用例,测试覆盖率应达到90%以上
  2. 测试类型: 包含单元测试和集成测试
  3. 测试环境: 测试应在沙箱环境中进行,避免影响生产数据

Git工作流

分支策略

提交信息规范

提交信息应遵循以下格式:

type类型:

示例:

版本管理

遵循语义化版本规范(SemVer):

支持的快递公司

各快递公司特定配置参数

邮政EMS (ems)

参数说明:

顺丰速运 (sf)

参数说明:

韵达快递 (yunda)

参数说明:

中通快递 (zto)

参数说明:

申通快递 (sto)

参数说明:

菜鸟网络 (cainiao)

参数说明:

技术依赖

许可证

Apache License 2.0

贡献

欢迎提交Issue和Pull Request!

联系我们

如有问题或建议,请通过以下方式联系:


All versions of express-api with dependencies

PHP Build Version
Package Version
Requires php Version ^7.4|^8.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 kode/express-api contains the following files

Loading the files please wait ...