PHPackages                             yii2framework/yiiframe-logistics - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. yii2framework/yiiframe-logistics

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

yii2framework/yiiframe-logistics
================================

A logistics SDK.

1.0.0(9mo ago)0229↑50%MITPHP

Since Aug 3Pushed 9mo agoCompare

[ Source](https://github.com/yii2framework/yiiframe-logistics)[ Packagist](https://packagist.org/packages/yii2framework/yiiframe-logistics)[ RSS](/packages/yii2framework-yiiframe-logistics/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (3)Versions (2)Used By (0)

❤️ Logistics
============

[](#️-logistics)

快递物流查询-快递查询接口组件，目前已支持阿里云、聚合数据、快递100、快递鸟四家平台。

[![Latest Stable Version](https://camo.githubusercontent.com/6d5937a53dfa7fdefe89edfcf7594dfb594e84eee62b3778d886e5e3a8108935/687474703a2f2f706f7365722e707567782e6f72672f796969326672616d65776f726b2f7969696672616d652d6c6f676973746963732f76)](https://packagist.org/packages/yii2framework/yiiframe-logistics) [![Total Downloads](https://camo.githubusercontent.com/c46e15cef7e63dcc139d181c8ea39ac3e8de604960fc1bbfa1e224f46af2a2bb/687474703a2f2f706f7365722e707567782e6f72672f796969326672616d65776f726b2f7969696672616d652d6c6f676973746963732f646f776e6c6f616473)](https://packagist.org/packages/yii2framework/yiiframe-logistics) [![Latest Unstable Version](https://camo.githubusercontent.com/104fcb0c98f3e54bac073072bacac5196a4e0c0ef35926f68fa321ed06ea7529/687474703a2f2f706f7365722e707567782e6f72672f796969326672616d65776f726b2f7969696672616d652d6c6f676973746963732f762f756e737461626c65)](https://packagist.org/packages/yii2framework/yiiframe-logistics) [![License](https://camo.githubusercontent.com/464b5129482881a4df2c20b55a7f60b51ff08fe661e7b112dc2c14b569dcf35a/687474703a2f2f706f7365722e707567782e6f72672f796969326672616d65776f726b2f7969696672616d652d6c6f676973746963732f6c6963656e7365)](https://packagist.org/packages/yii2framework/yiiframe-logistics) [![PHP Version Require](https://camo.githubusercontent.com/e874c2a9462cf532f24e23be9264ac500d1bc529373459f0d5529cd6123086e7/687474703a2f2f706f7365722e707567782e6f72672f796969326672616d65776f726b2f7969696672616d652d6c6f676973746963732f726571756972652f706870)](https://packagist.org/packages/yii2framework/yiiframe-logistics)

⚠️ 更新提示
-------

[](#️-更新提示)

1. 物流查询方法修改为：`$order = $logistics->query('805741929402797742', '圆通');`
2. 快递100 类名由 `Kuaidi100` 修改为 `Kd100`
3. 返回物流状态已统一,具体请查看：`src/Interfaces/LogisticsStatus.php`
4. 抽象物流状态为五种结果：
    - `has_active`: 是否已经有动态
    - `has_ended`: 动态是否已经截止
    - `has_signed`: 是否签收
    - `has_troubled`: 是否问题件
    - `has_returned`: 是否退回件
5. 修改Interfaces/Aliyun LOGISTICS\_INFO\_URL = '';
6. 修改Providers/Aliyun query方法里 'no' =&gt; $no,

介绍
--

[](#介绍)

目前已支持四家平台

- [阿里云](https://homenew.console.aliyun.com/)
- [聚合数据](https://www.juhe.cn/docs/api/id/43)
- [快递100](https://www.kuaidi100.com/)
- [快递鸟](https://www.kdniao.com/)

安装
--

[](#安装)

```
$ composer require yii2framework/yiiframe-logistics -vvv

```

使用
--

[](#使用)

```
require __DIR__ .'/vendor/autoload.php';

use yiiframe\logistics\Logistics;

$config = [
    'provider' => 'aliyun', // aliyun/juhe/kd100

    'aliyun' => [
        'app_code' => 'xxxxxxxx',
    ],

    'juhe' => [
         'app_code' => 'xxxxx',
    ],

    'kdniao' => [
             'app_code' => 'xxxxx',
             'customer' => 'xxxxx',
    ],

    'kd100' => [
         'app_code' => 'xxxxx',
         'customer' => 'xxxxx',
    ],
];

$logistics = new Logistics($config);
```

### 获取物流公司列表

[](#获取物流公司列表)

```
$companies = $logistics->companies();
```

示例:

```
[
    "顺丰",
    "申通",
    "中通",
    "圆通"
]
```

### 获取物流信息

[](#获取物流信息)

```
$order = $logistics->query('805741929402797742', '圆通');
```

示例：

```
{
    "code": 200,
    "msg": "OK",
    "company": "圆通",
    "no": "805741929402797742",
    "status": 4,
    "display_status": "已签收",
    "abstract_status": {
        "has_active" : true,
        "has_ended" : true,
        "has_signed" : true,
        "has_troubled" : false,
        "has_returned" : false
    },
    "list": [
        {
            "datetime": "2019-05-07 18:02:27",
            "remark": "山东省淄博市淄川区三部公司取件人:司健（15553333300）已收件",
            "zone": ""
        },
        {
            "datetime": "2019-05-09 12:44:40",
            "remark": "快件已签收签收人:邮件收发章感谢使用圆通速递，期待再次为您服务",
            "zone": ""
        }
    ],
    "original": {
        "resultcode": "200",
        "reason": "成功的返回",
        "result": {
            "company": "圆通",
            "com": "yt",
            "no": "805741929402797742",
            "status": "1",
            "status_detail": null,
            "list": [
                {
                    "datetime": "2019-05-07 18:02:27",
                    "remark": "山东省淄博市淄川区三部公司取件人:司健（15553333300）已收件",
                    "zone": ""
                },
                {
                    "datetime": "2019-05-09 12:44:40",
                    "remark": "快件已签收签收人:邮件收发章感谢使用圆通速递，期待再次为您服务",
                    "zone": ""
                }
            ]
        },
        "error_code": 0
    }
}
```

你也可以这样获取：

```
$order['company']; // '圆通' （因为各个平台对公司的名称有所不一致，所以查询结果或许会有些许差别）
$order['list']; // ....
$order['original']; // 获取接口原始返回信息
...

```

或者这样：

```
$order->getCode(); // 状态码
$order->getMsg(); // 状态信息
$order->getCompany(); // 物流公司简称
$order->getNo(); // 物流单号
$order->getStatus(); // 当前物流单状态

// 注：物流状态可能不一定准确

$order->getDisplayStatus(); // 当前物流单状态展示名
$order->getAbstractStatus(); // 当前抽象物流单状态
$order->getCourier(); // 快递员姓名
$order->getCourierPhone(); // 快递员手机号
$order->getList(); // 物流单状态详情
$order->getOriginal(); // 获取接口原始返回信息

```

### 参数说明

[](#参数说明)

```
 string   order(string $no, string $company = null)

```

> - `$no` - 物流单号
> - `$company` - 快递公司名（通过 $companies = $logistics-&gt;companies(); 获取)

- `aliyun` ：`$company` 可选
- `juhe` : `$company` 必填
- `kd100` : `$company` 可选（建议必填，不填查询结果不一定准确）
- `kdniao` : `$company` 可选（建议必填，不填查询结果不一定准确）

### 在 Laravel 中使用

[](#在-laravel-中使用)

生成配置文件

```
php artisan vendor:publish --provider="yii2framework\yiiframe-logistics\ServiceProvider"
```

然后在 `.env` 中配置 `LOGISTICS_APP_CODE` ，同时修改 config/logistics.php 中配置信息：

```
LOGISTICS_APP_CODE=xxxxxxxxxxxxxxxxx
LOGISTICS_CUSTOMER=xxxxxxxxxxxxxxxxx	// 快递100 customer
```

可以用两种方式来获取 `yii2framework\yiiframe-logistics\Logistics;` 实例：

#### 方法参数注入

[](#方法参数注入)

```
    .
    .
    .
    public function show(Logistics $logistics, $no, $company)
    {
        $order = $logistics->query($no, $company);

        return $order;	// $order->getList(); .....
    }
    .
    .
    .
```

#### 服务名访问

[](#服务名访问)

```
    .
    .
    .
    public function show($no, $company)
    {
        $response = app('logistics')->query($no, $company);
    }
    .
    .
    .
```

参考
--

[](#参考)

- [PHP 扩展包实战教程 - 从入门到发布](https://learnku.com/courses/creating-package)
- [overtrue/easy-sms](https://github.com/overtrue/easy-sms)
- [icecho/easy-ip](https://github.com/icecho/easy-ip)

感谢
--

[](#感谢)

- 感谢 [超哥](https://github.com/overtrue) 和 [icecho](https://github.com/icecho) 为我第一个扩展包的悉心指导。

License
-------

[](#license)

MIT

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance56

Moderate activity, may be stable

Popularity14

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity36

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

288d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/c94d4d584702ab50692474eece6c6f94db063220347f2c7f8979208e34cd7cb9?d=identicon)[yii2framework](/maintainers/yii2framework)

---

Top Contributors

[![hjp1011](https://avatars.githubusercontent.com/u/15049554?v=4)](https://github.com/hjp1011 "hjp1011 (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/yii2framework-yiiframe-logistics/health.svg)

```
[![Health](https://phpackages.com/badges/yii2framework-yiiframe-logistics/health.svg)](https://phpackages.com/packages/yii2framework-yiiframe-logistics)
```

###  Alternatives

[shlinkio/shlink

A self-hosted and PHP-based URL shortener application with CLI and REST interfaces

4.8k4.3k](/packages/shlinkio-shlink)[ralphjsmit/laravel-helpers

A package containing handy helpers for your Laravel-application.

13704.6k2](/packages/ralphjsmit-laravel-helpers)[dhlparcel/magento2-plugin

DHL Parcel plugin for Magento 2

11180.5k2](/packages/dhlparcel-magento2-plugin)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
