Download the PHP package wiewind/dhl-php-api without Composer

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

Wiewind DHL PHP API

基于 DHL 原生 REST API 的 PHP 封装,包含三个模块:

模块 命名空间 API 用途
Shipment Wiewind\DHL\Shipment Parcel DE Shipping v2(POST /parcel/de/shipping/v2/orders) 生成出/境内运单,返回运单号、运单 PDF、出口海关报关单
Returns Wiewind\DHL\Returns Parcel DE Returns v1(POST /parcel/de/shipping/returns/v1/orders) 生成退货运单,返回退货运单号、退货标签、退货二维码
Tracking Wiewind\DHL\Tracking Shipment Tracking - Unified(GET /track/shipments) 根据运单号查询包裹状态与完整轨迹

目录结构

安装

通过 Composer 安装:

然后引入 Composer 的自动加载器即可,三个模块均通过 PSR-4 按需自动加载:

环境要求:PHP ≥ 7.4,并启用 ext-curl、ext-json 扩展。






Shipment 模块(运单生成)

通过 DHL Parcel DE Shipping API v2 生成运单,可返回:运单号、运单 PDF、出口海关报关单 PDF。

类结构

类 说明
Credentials 连接配置 + 构建请求信封 + 发起请求 + 解析响应
Order 单个运单(产品、客户号、重量、尺寸、海关);toArray() 自动剔除空字段
Customs 出口报关声明,触发生成报关单
Item 报关商品明细行(描述、数量、价值、原产国、HS 编码)
Address 地址基类;Shipper、Consignee 继承它
Label 把 base64 PDF 保存到文件或输出到浏览器

快速开始

完整示例见 example/shipment.php,命令行运行:

核心流程:

run() 返回结构

文档选项(query 参数)

Credentials 默认请求嵌入式 PDF:

选项 默认值 说明
docFormat PDF PDF 或 ZPL2
includeDocs include include=内嵌 base64,URL=返回链接
combine false setCombine(true) 把运单+报关单合并为一个 PDF
printFormat (空) 标签版式,如 setPrintFormat('910-300-700')

注意事项






Returns 模块(退货运单)

通过 DHL Parcel DE Returns API v1 生成退货(Retoure)运单,可返回:退货运单号、退货标签 PDF、退货二维码(QR Label)。

类结构

类 说明
Credentials 连接配置 + 发起请求 + 解析响应
Order 退货单(退货收件人、寄件人、参考号、重量、价值、报关明细)
Shipper 退货寄件人(即退货的客户)
Item 报关商品明细行(国际退货时使用)
Label 把 base64 PDF/PNG 保存到文件或输出到浏览器

快速开始

完整示例见 example/returns.php,命令行运行:

核心流程:

run() 返回结构

注意事项






Tracking 模块(包裹追踪)

通过 DHL Shipment Tracking - Unified API 根据运单号查询包裹的当前状态与完整轨迹。

该模块鉴权方式与另外两个不同:仅用 DHL-API-Key 请求头,无需用户名/密码。

类结构

类 说明
Credentials 连接配置 + 发起 GET 请求 + 解析响应
Shipment 被追踪包裹模型,含当前状态及 Event 轨迹数组
Event 单条轨迹事件(时间、状态码、说明、地点)

快速开始

完整示例见 example/tracking.php,命令行运行:

核心流程:

run() 返回结构

Shipment 常用方法:getTrackingNumber()、getService()、getStatusCode()、 getStatus()、getStatusDetail()、getStatusTimestamp()、getOrigin()、 getDestination()、getEvents()、getLatestEvent()、isDelivered()。

可选查询参数

方法 说明
setService('parcel-de') 指定 DHL 服务(express / parcel-de / ecommerce / freight 等),加快查询
setLanguage('de') 返回文案语言(ISO 639-1)
setRequesterCountryCode('DE') 请求方国家(ISO 3166-1 alpha-2)
setOriginCountryCode('DE') 始发国家
setRecipientPostalCode('53113') 收件人邮编(部分服务用于校验)






生产环境配置

两个模块的凭证设置方式一致:

沙箱凭证已内置(DHL 公布的测试账号),可能被 DHL 更换,以开发者门户为准。 沙箱模式下 setUsername / setPassword 不生效,避免误改测试账号。


All versions of dhl-php-api with dependencies

PHP Build Version
Package Version
Requires php Version >=7.4
ext-curl 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 wiewind/dhl-php-api contains the following files

Loading the files please wait ...