PHPackages                             jswei/dawn-api - 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. jswei/dawn-api

ActiveLibrary[API Development](/categories/api)

jswei/dawn-api
==============

A RESTful API package for ThinkPHP5.1.\*

v1.0.3(6y ago)079Apache-2.0PHP

Since Feb 27Pushed 6y ago1 watchersCompare

[ Source](https://github.com/js-wei/dawn-api)[ Packagist](https://packagist.org/packages/jswei/dawn-api)[ RSS](/packages/jswei-dawn-api/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependencies (1)Versions (14)Used By (0)

Dawn-Api
========

[](#dawn-api)

[![Latest Stable Version](https://camo.githubusercontent.com/73837d1967171be5e14fc1fa01551bd6609fc3b4c2d13a6ddfc80076fa308a3f/68747470733a2f2f706f7365722e707567782e6f72672f6c697573686f756b756e2f6461776e2d6170692f762f737461626c65)](https://packagist.org/packages/liushoukun/dawn-api)[![Total Downloads](https://camo.githubusercontent.com/13c94f31a3cbecc7e07c218369a7a17f1a764bd9fa18f2a167d65daca4e79def/68747470733a2f2f706f7365722e707567782e6f72672f6c697573686f756b756e2f6461776e2d6170692f646f776e6c6f616473)](https://packagist.org/packages/liushoukun/dawn-api)[![Latest Unstable Version](https://camo.githubusercontent.com/e73adc07553185408361c3d004ac4df5a1a6fb123cc9ec7d86d8a7695244e5bf/68747470733a2f2f706f7365722e707567782e6f72672f6c697573686f756b756e2f6461776e2d6170692f762f756e737461626c65)](https://packagist.org/packages/liushoukun/dawn-api)[![License](https://camo.githubusercontent.com/f40db11df761d3164c5d1275b6d2c44adbdadec498304cdee84458456055d4c1/68747470733a2f2f706f7365722e707567782e6f72672f6c697573686f756b756e2f6461776e2d6170692f6c6963656e7365)](https://packagist.org/packages/liushoukun/dawn-api)[![Monthly Downloads](https://camo.githubusercontent.com/71a22a162c5fcc4d04556fa823a3e2a9751d98211a2f229735acb77a93fad6c5/68747470733a2f2f706f7365722e707567782e6f72672f6c697573686f756b756e2f6461776e2d6170692f642f6d6f6e74686c79)](https://packagist.org/packages/liushoukun/dawn-api)

说明
--

[](#说明)

ThinkPHP5编写的restful风格的API，集API请求处理，权限认证，自动生成文档等功能；

- restful风格处理请求

> 每个接口对于一个控制器，method对应\[method\]方法响应

- 权限认证

> Basic,Oauth Client Credentials Grant

- 文档生成

> 简洁，优雅，不需要额外的文档工具;

- 包已经进行了ThinkPHP5.1.\*的适配

> 已经对包进行了ThinkPHP5.1.\*的适配,并且将token生成改变了机制(原先的生成方式已被废弃) ,并且引入了注解路由进行文档的生成.更方便了使用

- 关于dawn-api说明

1. 为了方便使用这里讲修改过的dawn-api也提交到项目中了
2. 原先下载是的是没有适配后的dawn-api所以不支持ThinkPHP5.1.\*
3. 项目克隆下就可以使用了

安装
--

[](#安装)

- 如果想在你的TP5项目中使用,那么可以直接使用

```
composer require jswei/dawn-api

```

- 如果要使用生成文档 需要在public/static/ 下 安装hadmin

```
cd /public/static/
git clone  https://github.com/js-wei/hadmin.git

```

v0.0.4版本
--------

[](#v004版本)

1. 修复ThinkPHP更新出现的BUG
2. 生成文档API优化

功能增强
----

[](#功能增强)

### 关于dawn-api更改的部分

[](#关于dawn-api更改的部分)

> 这里再次对dawn-api进行了改动,下面就更改的一些地方进行说明

1. 优化并使用了自动加载扩展函数,解放了每次都要手动在`extraActionList`书写的问题
2. Wiki文档可以使用注解进行标记了,解放了需要在`getRules()`中写参数才能显示的问题,当然,只是做优化,您还可以写在里面,在这里我主要使用注解方式.下面是注解的用法,以login为例:

    ```
    /**
          * @title 用户登录
          * @method login
          * @param string $phone 账号 true
          * @param string $password 密码 true md5
          * @route('v1/user/login')
          * @return Object User 用户信息
        */

    ```

    - @title 接口名称
    - @method 注解的方法,表现为Wiki方法`login`的接口参数说明
    - @param 参数列表,以一个空格隔开.形如:\[数据类型 形参 参数名称 是否必须 备注说明 取值范围\]
    - @route 注解路由,在wiki的表现形式是将路由显示在方法后面
    - @return 返回的数据类型,以一个空格隔开.形如:\[数据类型 参数名称 备注说明\]
    - 完成后的效果:

    [![注解显示效果](https://camo.githubusercontent.com/f761529630127b6c720105dc19b1006242af13f0ed00b526142298eee4253a25/68747470733a2f2f7777772e696d6167652e6a737765692e636e2f6461776e2f6c6f67696e2e706e67)](https://camo.githubusercontent.com/f761529630127b6c720105dc19b1006242af13f0ed00b526142298eee4253a25/68747470733a2f2f7777772e696d6167652e6a737765692e636e2f6461776e2f6c6f67696e2e706e67)
3. 配合使用ThinkPHP5.1.\*的注解路由更家灵活多变,上面的例子就用到了注解路由,更多有关于注解路由[请参考](https://www.kancloud.cn/manual/thinkphp5_1/469333)

### 关于dawn-api说明

[](#关于dawn-api说明)

1. 为了方便使用这里讲修改过的dawn-api也提交到项目中了
2. 原先下载是的是没有适配后的dawn-api所以不支持ThinkPHP5.1.\*
3. 关于其他的配置以及wiki的配置,请参见dawn-api的说明
4. 修改的不太成熟,如有问题请提出

### 新增了命令行工具

[](#新增了命令行工具)

> 为了方便使用在这里新增了命令行工具,使用命令行工具可以快速的创建API控制器,下面做简单的介绍

1. 进入项目目录后,输入`php ./think`可以查看可以使用的命令行,看到了`api`,就表示可以使用提供的命令行工具了,显示如图:

[![命令行](https://camo.githubusercontent.com/d4891e2c8971c7a3e2efb4e7644505666839594de674b166c3ac627046580788/68747470733a2f2f7777772e696d6167652e6a737765692e636e2f6461776e2f6c696e6530312e706e67)](https://camo.githubusercontent.com/d4891e2c8971c7a3e2efb4e7644505666839594de674b166c3ac627046580788/68747470733a2f2f7777772e696d6167652e6a737765692e636e2f6461776e2f6c696e6530312e706e67)

2. 使用命令`php ./think api -s first -c news`创建一个命名空间为`first`名称为`news`的控制器,运行命令后出现了`Success`就创建成功了.如图:

[![wiki文档](https://camo.githubusercontent.com/eb0ce3b6bd2595b8a4a14c9eaaa05f67577867006f13bdb48dcd2a1293c80905/68747470733a2f2f7777772e696d6167652e6a737765692e636e2f6461776e2f6c696e6530322e706e67)](https://camo.githubusercontent.com/eb0ce3b6bd2595b8a4a14c9eaaa05f67577867006f13bdb48dcd2a1293c80905/68747470733a2f2f7777772e696d6167652e6a737765692e636e2f6461776e2f6c696e6530322e706e67)

3. 命令执行成功后你会看到在项目中`application\first\controller`中多出了一个名为`News.php`的文件,这个就是为你生成的一些方法.
4. 在生成控制器的同时还在配置文件`api_doc.php`生成了相应的文档的相关配置,如图:

[![wiki文档](https://camo.githubusercontent.com/eb0cee7f1ba6a18cce21527984482d5ae1fdfe14b757cac1a8c1f7261e5a268c/68747470733a2f2f7777772e696d6167652e6a737765692e636e2f6461776e2f6c696e6530332e706e67)](https://camo.githubusercontent.com/eb0cee7f1ba6a18cce21527984482d5ae1fdfe14b757cac1a8c1f7261e5a268c/68747470733a2f2f7777772e696d6167652e6a737765692e636e2f6461776e2f6c696e6530332e706e67)

5. 打开wiki这时就可以看见基本的相关api的文档说明,如图:

[![wiki文档](https://camo.githubusercontent.com/ecf7044b5dafa20da9817148d041ef4e0b20ec3e8ece203724782f718cd72bcb/68747470733a2f2f7777772e696d6167652e6a737765692e636e2f6461776e2f6c696e6530342e706e67)](https://camo.githubusercontent.com/ecf7044b5dafa20da9817148d041ef4e0b20ec3e8ece203724782f718cd72bcb/68747470733a2f2f7777772e696d6167652e6a737765692e636e2f6461776e2f6c696e6530342e706e67)

6. 这时候点击api地址可以测试是否成功(这里使用的是BaseAuth,浏览器提示登录窗口).如图:

[![wiki文档](https://camo.githubusercontent.com/1ab875877e30c13ab8fa4008349d9bd6f403af0cf76a52d857f4c69c06e49416/68747470733a2f2f7777772e696d6167652e6a737765692e636e2f6461776e2f6c696e6530352e706e67)](https://camo.githubusercontent.com/1ab875877e30c13ab8fa4008349d9bd6f403af0cf76a52d857f4c69c06e49416/68747470733a2f2f7777772e696d6167652e6a737765692e636e2f6461776e2f6c696e6530352e706e67)

> 需要注意的是因为开启了注解路由,创建成功之后最好执行路由生成工具,重新生成路由.

### api命令号的说明

[](#api命令号的说明)

> 下面主要介绍一下提供的参数,方便您使用

1. 首先,你可以使用`php ./think api -h`查看帮助,您将得到的结果如下:

[![wiki文档](https://camo.githubusercontent.com/1b3db3c813dd56be1426ef1b536315bcf2f5cad957be40131ef7b7f5932aaa98/68747470733a2f2f7777772e696d6167652e6a737765692e636e2f6461776e2f6c696e6530362e706e67)](https://camo.githubusercontent.com/1b3db3c813dd56be1426ef1b536315bcf2f5cad957be40131ef7b7f5932aaa98/68747470733a2f2f7777772e696d6167652e6a737765692e636e2f6461776e2f6c696e6530362e706e67)

- -s or --namespace 生成的控制器的命名空间
- -c or --controller 生成的控制器的名称
- -i or --id 生成的文档配置的id,默认是根据原配置一次增加
- -p or --parent 作为一个文档的子节点的父亲id,默认是0顶级节点
- 看一些列子

1. ` php ./think api -s first -c sub -p 5 #为id为5的创建一个字文档,id自增`
2. `php ./think api -s first -c sub1 -i 8 #创建一个id为8的文档节点,父级为顶级`
3. `php ./think api -s first -c sub2 -i 9 -p 5 #创建一个id为5的创建一个id为9的子级文档节点`

运行成功后:

[![wiki文档02](https://camo.githubusercontent.com/978011d263bf228cc37e66fa7b9dc330a3b69635b8947ee8d699c8d673cf39cf/68747470733a2f2f7777772e696d6167652e6a737765692e636e2f6461776e2f6c696e6530372e706e67)](https://camo.githubusercontent.com/978011d263bf228cc37e66fa7b9dc330a3b69635b8947ee8d699c8d673cf39cf/68747470733a2f2f7777772e696d6167652e6a737765692e636e2f6461776e2f6c696e6530372e706e67)

[![wiki文档03](https://camo.githubusercontent.com/1cbe75d848a187633afbecfbdf32e04beca3ad7bcfa420c92dac3d263a549237/68747470733a2f2f7777772e696d6167652e6a737765692e636e2f6461776e2f6c696e6530382e706e67)](https://camo.githubusercontent.com/1cbe75d848a187633afbecfbdf32e04beca3ad7bcfa420c92dac3d263a549237/68747470733a2f2f7777772e696d6167652e6a737765692e636e2f6461776e2f6c696e6530382e706e67)

[![wiki文档04](https://camo.githubusercontent.com/a2e71c1321825a67b7c8eb8971a2952f472fb240f6593cb9df87cda12314f0f7/68747470733a2f2f7777772e696d6167652e6a737765692e636e2f6461776e2f6c696e6530392e706e67)](https://camo.githubusercontent.com/a2e71c1321825a67b7c8eb8971a2952f472fb240f6593cb9df87cda12314f0f7/68747470733a2f2f7777772e696d6167652e6a737765692e636e2f6461776e2f6c696e6530392e706e67)

[![wiki文档04](https://camo.githubusercontent.com/b37732560fd8e87c590552235973ef02aa185761b4b9167353202e16a300ec38/68747470733a2f2f7777772e696d6167652e6a737765692e636e2f6461776e2f6c696e6531302e706e67)](https://camo.githubusercontent.com/b37732560fd8e87c590552235973ef02aa185761b4b9167353202e16a300ec38/68747470733a2f2f7777772e696d6167652e6a737765692e636e2f6461776e2f6c696e6531302e706e67)

### 在线的例子

[](#在线的例子)

[在线示例WIKI](http://api.jswei.cn/wiki)

[Postman接口文档](https://documenter.getpostman.com/view/4206182/RW1dHKCt)

###  Health Score

29

—

LowBetter than 59% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity67

Established project with proven stability

 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

Every ~16 days

Recently: every ~5 days

Total

13

Last Release

2434d ago

Major Versions

v0.0.9 → v1.0.02019-08-23

### Community

Maintainers

![](https://www.gravatar.com/avatar/0f510c9b1712074bcda122341d4c11237f486cbbff1d0ebe60a3786c9294f7f4?d=identicon)[js-wei](/maintainers/js-wei)

---

Top Contributors

[![js-wei](https://avatars.githubusercontent.com/u/10104372?v=4)](https://github.com/js-wei "js-wei (18 commits)")

### Embed Badge

![Health badge](/badges/jswei-dawn-api/health.svg)

```
[![Health](https://phpackages.com/badges/jswei-dawn-api/health.svg)](https://phpackages.com/packages/jswei-dawn-api)
```

###  Alternatives

[naixiaoxin/think-wechat

EasyWechat For Thnkphp5.1+

27316.1k1](/packages/naixiaoxin-think-wechat)[weiwei/api-doc

The ThinkPHP6 Api Doc Package

10710.2k](/packages/weiwei-api-doc)

PHPackages © 2026

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