PHPackages                             lany/mingdaoyun - 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. lany/mingdaoyun

ActiveLibrary[API Development](/categories/api)

lany/mingdaoyun
===============

明道云API SDK

1.5.0(2y ago)101.2k↓50%1[1 issues](https://github.com/Lany-w/mingdaoyun-php-sdk/issues)MITPHPPHP &gt;=7.4

Since Jan 4Pushed 2y ago3 watchersCompare

[ Source](https://github.com/Lany-w/mingdaoyun-php-sdk)[ Packagist](https://packagist.org/packages/lany/mingdaoyun)[ RSS](/packages/lany-mingdaoyun/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (4)Versions (26)Used By (0)

mingdaoyun-PHP-SDK
==================

[](#mingdaoyun-php-sdk)

针对mingdaoyun的API封装的PHP-SDK包

Python 版本：

Features
--------

[](#features)

- 封装基础API
- 固定数据的CRUD
- syncToDB 功能
- 明道云组织架构接口

Installing
----------

[](#installing)

```
$ composer require lany/mingdaoyun
```

Usage
-----

[](#usage)

- Laravel (&gt;=5.5) `1.2.0开始支持`

    发布配置文件

```
$ php artisan vendor:publish --provider="Lany\MingDaoYun\Provider\ServiceProvider"
```

修改`.env`,添加配置

```
MINGDAOYUN_APP_KEY=xxx
MINGDAOYUN_SIGN=xxx
MINGDAOYUN_HOST=http://xxx.com
```

示例代码

```
use Lany\MingDaoYun\MingDaoYun;
class IndexController extends Controller
{
   //依赖注入方式
   public function index(MingDaoYun $mdy)
   {
       $data = $mdy->table('60efbf797b786d8a492bfcee')->get();
       dd($data);
   }
   //实例化服务方式
   public function index1()
   {
        $data = app('mdy')->table('60efbf797b786d8a492bfcee')->get();
        dd($data);
   }
}

```

- ThinkPHP (&gt;=5.1) `1.2.0开始支持`

> `5.1`请手动 `use Lany\MingDaoYun\Facade\MingDaoYun;` 使用, `6.0以上`可以使用下面的方式

修改`.env`,添加配置

```
MINGDAOYUN_APP_KEY=xxx
MINGDAOYUN_SIGN=xxx
MINGDAOYUN_HOST=http://xxx.com
```

示例代码

```
class Index extends BaseController
{

   public function hello($name = 'ThinkPHP6')
   {
       $data = app('mdy')->table('60efbf797b786d8a492bfcee')->get();
       var_dump($data);
   }
}
```

- Other

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

use Lany\MingDaoYun\Facade\MingDaoYun;

$appKey = "APPKEY"; //明道云APPKEY
$sign = "SIGN"; //明道云SIGN
$host = "http://xxx.xxx.com"; //私有部署域名
$mdy = MingDaoYun::init($appKey, $sign, $host);
$data = $mdy->table('worksheetId')->get();
```

Function
--------

[](#function)

- [init](#init)
- [table](#table)
- [limit](#limit)
- [page](#page)
- [fieldMap](#fieldMap)
- [with](#with)
- [sort](#sort)
- [whereOr](#whereOr)
- [where](#where)
- [whereIn](#whereIn)
- [whereNull](#whereNull)
- [whereNotNull](#whereNotNull)
- [whereDate](#whereDate)
- [whereNotDate](#whereNotDate)
- [get](#get)
- [find](#find)
- [relations](#relations)
- [view](#view)
- [insert](#insert)
- [create](#create)
- [delete](#delete)
- [update](#update)
- [updateRows](#updateRows)
- [all](#all)
- [count](#count)
- [dateRange](#dateRange)
- [notDateRange](#notDateRange)
- [customize](#customize)
- [同步数据到本地数据库](#%E5%90%8C%E6%AD%A5%E6%95%B0%E6%8D%AE%E5%88%B0%E6%9C%AC%E5%9C%B0%E6%95%B0%E6%8D%AE%E5%BA%93)
- [workflow](#workflow)
- [notGetTotal](#notGetTotal)
- [whereBetween](#whereBetween)
- [whereNotBetween](#whereNotBetween)
- [whereGroup](#whereGroup)

### init

[](#init)

> 设置初始化参数

```
$mdy = MingDaoYun::init('APPKEY', 'SIGN', '部署域名');
```

### table

[](#table)

> 设置工作表

```
$mdy->table('worksheetId');
```

### limit

[](#limit)

> 要获取的数据行数

```
$mdy->table('worksheetId')->limit(5);
```

### page

[](#page)

> 设置页码

```
$mdy->table('worksheetId')->page(5);
```

### fieldMap

[](#fieldmap)

> 获取字段对照关系(明道云工作表结构)

```
$mdy->table('worksheetId')->fieldMap();
```

### with

[](#with)

> 要获取关联记录时,设置rowId,controlId

```
$mdy->table('worksheetId')->with('rowId', 'controlId');
```

### relations

[](#relations)

> 获取关联记录
> 1.1.1修改为默认获取100条关联记录,`relations(true)`获取所有关联记录

```
$mdy->table('worksheetId')->with('rowId', 'controlId')->relations();
```

### sort

[](#sort)

> 设置排序字段,默认为升序

```
$mdy->table('worksheetId')->sort('field', $bool);
```

### whereOr

[](#whereor)

> 设置筛选条件,以or的方式拼接下一个条件,使用whereOr时必须写在where()之前

```
$mdy->table('worksheetId')->whereOr('field', '=', '123');
```

### where

[](#where)

> 设置筛选条件,以and的方式拼接下一个条件,目前支持的运算符有`contains`,`notContain`,`startWith`,`endWith`,`=`,`!=`,`>`,`>=`,`where('field', '!=', '123');
```

### whereIn

[](#wherein)

> wehreIn

```
$mdy->table('worksheetId')->whereIn('field', ['Lany', 'Todd', 'Dom']);
```

### whereNull

[](#wherenull)

> 字段为空

```
$mdy->table('worksheetId')->whereNull('field');
```

### whereNotNull

[](#wherenotnull)

> 字段为不为空

```
$mdy->table('worksheetId')->whereNotNull('field');
```

### whereDate

[](#wheredate)

> 日期是

```
$mdy->table('worksheetId')->whereDate('field', '2022-02-22');
```

### whereNotDate

[](#wherenotdate)

> 日期不是

```
$mdy->table('worksheetId')->whereNotDate('field', '2022-02-22');
```

### get

[](#get)

> 获取工作表内容
> `1.1.0`修改为默认最多获取1000条数据,如需获取更多数据请使用`limit`设置,获取所有数据请使用`all`

```
$mdy->table('worksheetId')->limit(1)->page(1)->get();
```

### find

[](#find)

> 获取单条记录(行记录详情)

```
$mdy->table('worksheetId')->find('rowId');
```

### view

[](#view)

> 设置视图ID

```
$mdy->table('worksheetId')->view('view')->get();
```

### insert

[](#insert)

> 新增单条记录,按明道云新增controls参数格式传入data即可

```
$data = [
    ['controlId' => 'controlId', 'value' => 'value'],
    ['controlId' => 'controlId', 'value' => 'value'],
];
$mdy->table('worksheetId')->insert($data);
```

### create

[](#create)

> 批量新增记录,按明道云批量新增rows参数格式传入data即可

```
$data = [
    [
        ['controlId' => 'controlId', 'value' => 'value'],
        ['controlId' => 'controlId', 'value' => 'value'],
    ],

];
$mdy->table('worksheetId')->create($data);
```

### delete

[](#delete)

> 删除行记录,多条记录以`,`分隔rowId

```
$mdy->table('worksheetId')->delete('rowId');
```

### update

[](#update)

> 更新单行记录

```
$update = [
    ['controlId' => '60efbf797b786d8a492bfce2', 'value' => '波波波力'],
    ['controlId' => '60efbf797b786d8a492bfce5', 'value' => '波波波力力力力力'],
];
$mdy->table('worksheetId')->update('rowId', $update);
```

### updateRows

[](#updaterows)

> 批量更新行记录,(目前明道只支持每次更新一个字段)

```
$rowIds = [
    'rowId1', 'rowId2'
];

$update = [
    'controlId' => 'controlId', 'value' => 'value'
];
$mdy->table('worksheetId')->updateRows($rowIds, $update);
```

### all

[](#all)

> 获取所有数据
> 此方法为`1.1.0新增`

```
$mdy->table('worksheetId')->all();
```

### count

[](#count)

> 统计数据行数
> 此方法为`1.1.0新增`
> keyword默认为空

```
$mdy->table('worksheetId')->count($keyword);
```

### dateRange

[](#daterange)

此方法为`1.4.0新增`

> 日期区间
> 支持`Today`,`Tomorrow`, `Yesterday`,`ThisWeek`,`Next7Day`, `Last14Day`等，具体可查看明道云文档 DateRange

```
$mdy->table('worksheetId')->dateRange('plan_date', 'Next14Day')->get();
```

### notDateRange

[](#notdaterange)

此方法为`1.4.0新增`

> 不在日期区间 支持`Today`,`Tomorrow`, `Yesterday`,`ThisWeek`,`Next7Day`, `Last14Day`等，具体可查看明道云文档 DateRange

```
$mdy->table('worksheetId')->notDateRange('plan_date', 'Next14Day')->get();
```

### customize

[](#customize)

此方法为`1.4.0新增`

> 自定义查询条件，按官方文档的格式传入数组参数

```
$customize = [
    "controlId" => "62d903e1347b8802573306d3",
    "dataType" => 30,
    "spliceType" => 1,
    "filterType" => 2,
    "value" => "Jinji"
]
$mdy->table('worksheetId')->customize($customize)->get();
```

### workflow

[](#workflow)

> `1.4.2` 是否触发工作流 默认为true

```
$mdy->table('worksheetId')->workflow(false);
```

### notGetTotal

[](#notgettotal)

> `1.4.2` 是否不统计总行数以提高性能 默认为false

```
$mdy->table('worksheetId')->notGetTotal(true);
```

### whereBetween

[](#wherebetween)

```
$mdy->table('worksheetId')->whereBetween('fq_time', ['2023-11-01 7:00:00', '2023-12-21 7:00:00']);
```

### whereNotBetween

[](#wherenotbetween)

```
$mdy->table('worksheetId')->whereNotBetween('fq_time', ['2023-11-01 7:00:00', '2023-12-21 7:00:00']);
```

### 同步数据到本地数据库

[](#同步数据到本地数据库)

> `1.2.0新增`
>
> Laravel和ThinkPHP5.1如果不存在数据表会自动创建(ThinkPHP6需先手动创建数据表),以明道云字段别名创建数据字段,如不存在别名则使用明道控件ID创建

- 修改对应的`Model`文件

```
class ProductItem extends Model implements SyncAdapter
{
    //Laravel
    use LaravelAdapter;
    //ThinkPHP
    use ThinkPHPAdapter;
}
```

- 调用`syncToDB`

```
    $data = app('mdy')->table('60efbf797b786d8a492bfcee')->all();
    \App\Models\ProductItem::syncToDB($data);
    //或者传入MingDaoYun实例
     $data = app('mdy')->table('60efbf797b786d8a492bfcee')->limit(1);
    \App\Models\ProductItem::syncToDB($data);
```

### whereGroup

[](#wheregroup)

1.5.0新增

> whereGroup($callable, $spliceType), spliceType为and/or,默认为and

```
$mdy->table('60f631095d106d99c054e0bd')->whereGroup(function(\Lany\MingDaoYun\MingDaoYun $mdy) {
    $mdy->whereOr('user', '=', 'Lany')->where('friend', '=', 'Dom');
})->where('desc', '=', 'test')
```

License
-------

[](#license)

MIT

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance18

Infrequent updates — may be unmaintained

Popularity25

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 59.3% 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 ~33 days

Recently: every ~90 days

Total

25

Last Release

803d ago

PHP version history (2 changes)1.0.0PHP ^7.4

1.2.0-BetaPHP &gt;=7.4

### Community

Maintainers

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

---

Top Contributors

[![Lany-w](https://avatars.githubusercontent.com/u/34297914?v=4)](https://github.com/Lany-w "Lany-w (118 commits)")[![ghostlitao](https://avatars.githubusercontent.com/u/2668428?v=4)](https://github.com/ghostlitao "ghostlitao (81 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/lany-mingdaoyun/health.svg)

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

###  Alternatives

[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.4k5.6M651](/packages/sylius-sylius)[tencentcloud/tencentcloud-sdk-php

TencentCloudApi php sdk

3731.2M42](/packages/tencentcloud-tencentcloud-sdk-php)[convertkit/convertkitapi

Kit PHP SDK for the Kit API

2167.1k1](/packages/convertkit-convertkitapi)[mapado/rest-client-sdk

Rest Client SDK for hydra API

1125.9k2](/packages/mapado-rest-client-sdk)

PHPackages © 2026

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