Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
L

logistics

> 编程语言
Open source

Logistics query extension package

185 stars0 likes0 views
WebsiteGitHub

About

Logistics query extension package

❤️ Logistics

快递物流查询-快递查询接口组件。

介绍

目前已支持四家平台

  • 阿里云
  • 聚合数据
  • 快递100
  • 快递鸟

安装

$ composer require finecho/logistics -vvv	
```	

## 使用	

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

use Finecho\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);
```	

###  获取物流公司列表
 
```php	
$companies = $logistics->companies();	
```	

示例:

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

获取物流信息

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

示例:

…

你也可以这样获取:

$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->companies(); 获取)
  • aliyun :$company 可选
  • juhe : $company 必填
  • kd100 : $company 可选(建议必填,不填查询结果不一定准确)
  • kdniao : $company 可选(建议必填,不填查询结果不一定准确)

在 Laravel 中使用

生成配置文件

php
php artisan vendor:publish --provider="Finecho\Logistics\ServiceProvider"

然后在 .env 中配置 LOGISTICS_APP_CODE ,同时修改 config/logistics.php 中配置信息:

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

可以用两种方式来获取 Finecho\Logistics\Logistics; 实例:

方法参数注入

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

#### 服务名访问	

```php	
    .	
    .	
    .	
    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	

MIT

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

PHPlogisticslogistics-company

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 18, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言