PHPackages                             finecho/meituan - 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. [API Development](/categories/api)
4. /
5. finecho/meituan

ActiveLibrary[API Development](/categories/api)

finecho/meituan
===============

美团开放平台SDK

1.0.4(3y ago)45588[1 issues](https://github.com/thisliu/easy-meituan/issues)MITPHPPHP &gt;=8.0

Since Dec 13Pushed 3y ago1 watchersCompare

[ Source](https://github.com/thisliu/easy-meituan)[ Packagist](https://packagist.org/packages/finecho/meituan)[ RSS](/packages/finecho-meituan/feed)WikiDiscussions main Synced today

READMEChangelog (5)Dependencies (10)Versions (6)Used By (0)

 finecho/meituan
=================

[](#-finechomeituan-)

 美团开放平台 SDK

温馨提示
----

[](#温馨提示)

⚠️ 目前仅支持美团外卖服务

安装
--

[](#安装)

环境要求：

- PHP &gt;= 8.0

```
composer require finecho/meituan -vvv
```

配置
--

[](#配置)

```
$config = [
    // 必填，app_id、secret_id
    'app_id' => 10020201024,
    'secret_id' => 'AKIDsiQzQla780mQxLLU2GJCxxxxxxxxxxx',

    // 是否开启表单验证
    'form_verify' => false,
];
```

使用
--

[](#使用)

您可以使用三种调用方式：封装方式调用、原始方式调用 和 链式调用，请根据你的喜好自行选择使用方式，效果一致。

### 方式一 - 封装方式调用

[](#方式一---封装方式调用)

```
use EasyMeiTuan\Application;

$app = new Application($config);

$response = $app->store->create(
    [
        'name'    => 'finecho 的快餐店',
        'address' => '深圳市南山区',
    ]
);

// 也可以这样
$response = $app->store->create(
    [
        'body' => [
            'name'    => 'finecho 的快餐店',
            'address' => '深圳市南山区',
        ],
        'headers' => [],
    ]
);
```

### 方式二 - 原始方式调用

[](#方式二---原始方式调用)

```
use EasyMeiTuan\Application;

$app = new Application($config);

$api = $app->getClient();

$response = $api->post(
    '/poi/save',
    [
        'name'    => 'finecho 的快餐店',
        'address' => '深圳市南山区',
    ]
);
```

### 方式三 - 链式调用

[](#方式三---链式调用)

你可以将需要调用的 API 以 / 分割 + 驼峰写法的形式，写成如下模式：

```
use EasyMeiTuan\Application;

$app = new Application($config);

$api = $app->getClient();

$response = $api->poi->save->post(
    [
        'name'    => 'finecho 的快餐店',
        'address' => '深圳市南山区',
    ]
);
```

表单校验
----

[](#表单校验)

如果开启表单校验，如果参数缺失或者异常，则会抛出 [InvalidParamsException](https://github.com/finecho/easy-meituan/blob/main/src/Exceptions/InvalidParamsException.php) 异常

美团推送
----

[](#美团推送)

在接收美团推送的时候，`Server` 会对签名进行校验，并返回解码后的内容

```
$server = $app->getServer();

// url：在美团外卖设置的回调地址
// content：美团外卖推送过来的内容, 在美团外卖开放平台配置回调地址美团服务器发起验证码时 content 为空数组
$server->withUrl($url)->with(
    function ($content) {
        // ...
    }
);

return $server->serve();
```

签名校验的时候, 需要将已编码的字段内容进行解码，SDK 提供属性可自行配置 decode 规则。

- url：对值进行 `urldecode`
- json：为对值进行 `json_decode(val, true)`

```
// 默认需要解码字段以及规则
\EasyMeiTuan\Server::$casts = [
    'caution' => 'url',
    'detail' => 'url|json',
    'extras' => 'url|json',
    'recipient_name' => 'url',
    'wm_poi_address' => 'url',
    'recipient_address' => 'url',
    'incmp_modules' => 'url|json',
    'order_tag_list' => 'url|json',
    'backup_recipient_phone' => 'url|json',
    'recipient_address_desensitization' => 'url',

    // FBI Warning: nested content needs to pay attention to the order!
    'poi_receive_detail_yuan' => 'url|json',
    'poi_receive_detail_yuan.reconciliationExtras' => 'json',
    'poi_receive_detail' => 'url|json',
    'poi_receive_detail.reconciliationExtras' => 'json',
];
```

API
---

[](#api)

API 接口众多，每一个 API 都会注释上美团文档地址，查询困难时，可以直接搜索匹配。

### 🌐 门店

[](#globe_with_meridians-门店)

[美团门店文档](https://developer.waimai.meituan.com/home/doc/food/1)

具体方法：[src/Services/Store.php](https://github.com/finecho/easy-meituan/blob/main/src/Services/Store.php)

```
$app->store->$method();
```

### 🚚 配送范围

[](#truck-配送范围)

[美团配送文档](https://developer.waimai.meituan.com/home/doc/food/2)

具体方法：[src/Services/DeliveryRange.php](https://github.com/finecho/easy-meituan/blob/main/src/Services/DeliveryRange.php)

```
$app->deliveryRange->$method();
```

### 📝 类目

[](#memo-类目)

[美团类目文档](https://developer.waimai.meituan.com/home/doc/food/3)

具体方法：[src/Services/Category.php](https://github.com/finecho/easy-meituan/blob/main/src/Services/Category.php)

```
$app->category->$method();
```

### 🍻 菜品

[](#beers-菜品)

[美团菜品文档](https://developer.waimai.meituan.com/home/doc/food/3)

具体方法：[src/Services/Product.php](https://github.com/finecho/easy-meituan/blob/main/src/Services/Product.php)

```
$app->product->$method();
```

### 📄 订单

[](#page_facing_up-订单)

[美团订单文档](https://developer.waimai.meituan.com/home/doc/food/6)

具体方法：[src/Services/Order.php](https://github.com/finecho/easy-meituan/blob/main/src/Services/Order.php)

```
$app->order->$method();
```

#### 🗑️ 订单退款

[](#wastebasket-订单退款)

具体方法：[src/Services/Refund.php](https://github.com/finecho/easy-meituan/blob/main/src/Services/Refund.php)

```
$app->refund->$method();
```

#### 🚚 订单配送

[](#truck-订单配送)

具体方法：[src/Services/Logistic.php](https://github.com/finecho/easy-meituan/blob/main/src/Services/Logistic.php)

```
$app->logistic->$method();
```

#### 📦 众包

[](#package-众包)

具体方法：[src/Services/CrowdSourcing.php](https://github.com/finecho/easy-meituan/blob/main/src/Services/CrowdSourcing.php)

```
$app->crowdSourcing->$method();
```

### 🔧 全局公共

[](#wrench-全局公共)

具体方法：[src/Services/Product.php](https://github.com/finecho/easy-meituan/blob/main/src/Services/Product.php)

```
$app->common->$method();
```

### 返回值

[](#返回值)

API Client 基于 [symfony/http-client](https://symfony.com/doc/current/http_client.html) 实现，你可以通过以下方式对响应值进行访问：

```
// 获取状态码
$statusCode = $response->getStatusCode();
// 获取全部响应头
$headers = $response->getHeaders();
// 获取响应原始内容
$content = $response->getContent();
// 获取 json 转换后的数组格式
$content = $response->toArray();
// 将内容转换成 Stream 返回
$content = $response->toStream();
// 获取其他信息，如："response_headers", "redirect_count", "start_time", "redirect_url" 等.
$httpInfo = $response->getInfo();
// 获取指定信息
$startTime = $response->getInfo('start_time');
// 获取请求日志
$httpLogs = $response->getInfo('debug');
```

在原有 Response 的基础上，增加了以下几种方法：

```
// 请求是否正常
$isSuccess = $response->isSuccess(): bool;
// 请求是否出现异常
$hasError = $response->hasError(): bool;
// 获取错误内容（code + msg）
$error = $response->getError(): array;
// 获取错误信息
$error = $response->getErrorMsg(): ?string;
// 获取错误码
$error = $response->getErrorCode(): string|int|null;
// 获取正常返回的数据
$data = $response->getData(): mixed;
```

一个比较完整的示例
---------

[](#一个比较完整的示例)

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

use EasyMeiTuan\Application;
use EasyMeiTuan\Exceptions\InvalidParamsException;

$config = [
    'app_id' => 'xxx',
    'secret_id' => 'xxxxxxxxxxx',
    'form_verify' => true,
];

$app = new Application($config);

try {
    $response = $app->store->list();

    if ($response->hasError()) {
        $error = $response->getError();

        // .....
    }

    $data = $response->getData();

    // ....

} catch (InvalidParamsException $e) {
    // 捕获到表单异常
}
```

License
-------

[](#license)

MIT

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity22

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 81.5% 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

Every ~127 days

Total

5

Last Release

1099d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/4c7d97a405bd4800085229fad21b5c81ead3f09393525289d764f99300b0f1ed?d=identicon)[liuhao](/maintainers/liuhao)

---

Top Contributors

[![thisliu](https://avatars.githubusercontent.com/u/29086766?v=4)](https://github.com/thisliu "thisliu (53 commits)")[![lonquan](https://avatars.githubusercontent.com/u/12944913?v=4)](https://github.com/lonquan "lonquan (8 commits)")[![uptutu](https://avatars.githubusercontent.com/u/23716080?v=4)](https://github.com/uptutu "uptutu (3 commits)")[![vito-97](https://avatars.githubusercontent.com/u/33369710?v=4)](https://github.com/vito-97 "vito-97 (1 commits)")

---

Tags

meituanmeituan-sdkphpphp-sdk

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/finecho-meituan/health.svg)

```
[![Health](https://phpackages.com/badges/finecho-meituan/health.svg)](https://phpackages.com/packages/finecho-meituan)
```

###  Alternatives

[kirschbaum-development/laravel-openapi-validator

Automatic OpenAPI validation for Laravel HTTP tests

581.1M5](/packages/kirschbaum-development-laravel-openapi-validator)[spatie/laravel-export

Create a static site bundle from a Laravel app

646127.9k5](/packages/spatie-laravel-export)[jasara/php-amzn-selling-partner-api

A fluent interface for Amazon's Selling Partner API in PHP

1344.8k1](/packages/jasara-php-amzn-selling-partner-api)[dariusiii/tmdb-laravel

Laravel Package for TMDB ( The Movie Database ) API. Provides easy access to the wtfzdotnet/php-tmdb-api library.

1821.1k](/packages/dariusiii-tmdb-laravel)[litalico-engineering/eg-r2

Easy request validation and route generation from open API specifications (for Laravel)

1112.5k](/packages/litalico-engineering-eg-r2)[aedart/athenaeum

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

255.2k](/packages/aedart-athenaeum)

PHPackages © 2026

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