20220406
This commit is contained in:
3
vendor/itxq/api-doc-php/.gitignore
vendored
Normal file
3
vendor/itxq/api-doc-php/.gitignore
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
/.idea
|
||||
/vendor/
|
||||
/composer.lock
|
||||
191
vendor/itxq/api-doc-php/LICENSE
vendored
Normal file
191
vendor/itxq/api-doc-php/LICENSE
vendored
Normal file
@@ -0,0 +1,191 @@
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction, and
|
||||
distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by the copyright
|
||||
owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all other entities
|
||||
that control, are controlled by, or are under common control with that entity.
|
||||
For the purposes of this definition, "control" means (i) the power, direct or
|
||||
indirect, to cause the direction or management of such entity, whether by
|
||||
contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity exercising
|
||||
permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications, including
|
||||
but not limited to software source code, documentation source, and configuration
|
||||
files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical transformation or
|
||||
translation of a Source form, including but not limited to compiled object code,
|
||||
generated documentation, and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or Object form, made
|
||||
available under the License, as indicated by a copyright notice that is included
|
||||
in or attached to the work (an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object form, that
|
||||
is based on (or derived from) the Work and for which the editorial revisions,
|
||||
annotations, elaborations, or other modifications represent, as a whole, an
|
||||
original work of authorship. For the purposes of this License, Derivative Works
|
||||
shall not include works that remain separable from, or merely link (or bind by
|
||||
name) to the interfaces of, the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including the original version
|
||||
of the Work and any modifications or additions to that Work or Derivative Works
|
||||
thereof, that is intentionally submitted to Licensor for inclusion in the Work
|
||||
by the copyright owner or by an individual or Legal Entity authorized to submit
|
||||
on behalf of the copyright owner. For the purposes of this definition,
|
||||
"submitted" means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems, and
|
||||
issue tracking systems that are managed by, or on behalf of, the Licensor for
|
||||
the purpose of discussing and improving the Work, but excluding communication
|
||||
that is conspicuously marked or otherwise designated in writing by the copyright
|
||||
owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity on behalf
|
||||
of whom a Contribution has been received by Licensor and subsequently
|
||||
incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License.
|
||||
|
||||
Subject to the terms and conditions of this License, each Contributor hereby
|
||||
grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free,
|
||||
irrevocable copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the Work and such
|
||||
Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License.
|
||||
|
||||
Subject to the terms and conditions of this License, each Contributor hereby
|
||||
grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free,
|
||||
irrevocable (except as stated in this section) patent license to make, have
|
||||
made, use, offer to sell, sell, import, and otherwise transfer the Work, where
|
||||
such license applies only to those patent claims licensable by such Contributor
|
||||
that are necessarily infringed by their Contribution(s) alone or by combination
|
||||
of their Contribution(s) with the Work to which such Contribution(s) was
|
||||
submitted. If You institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work or a
|
||||
Contribution incorporated within the Work constitutes direct or contributory
|
||||
patent infringement, then any patent licenses granted to You under this License
|
||||
for that Work shall terminate as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution.
|
||||
|
||||
You may reproduce and distribute copies of the Work or Derivative Works thereof
|
||||
in any medium, with or without modifications, and in Source or Object form,
|
||||
provided that You meet the following conditions:
|
||||
|
||||
You must give any other recipients of the Work or Derivative Works a copy of
|
||||
this License; and
|
||||
You must cause any modified files to carry prominent notices stating that You
|
||||
changed the files; and
|
||||
You must retain, in the Source form of any Derivative Works that You distribute,
|
||||
all copyright, patent, trademark, and attribution notices from the Source form
|
||||
of the Work, excluding those notices that do not pertain to any part of the
|
||||
Derivative Works; and
|
||||
If the Work includes a "NOTICE" text file as part of its distribution, then any
|
||||
Derivative Works that You distribute must include a readable copy of the
|
||||
attribution notices contained within such NOTICE file, excluding those notices
|
||||
that do not pertain to any part of the Derivative Works, in at least one of the
|
||||
following places: within a NOTICE text file distributed as part of the
|
||||
Derivative Works; within the Source form or documentation, if provided along
|
||||
with the Derivative Works; or, within a display generated by the Derivative
|
||||
Works, if and wherever such third-party notices normally appear. The contents of
|
||||
the NOTICE file are for informational purposes only and do not modify the
|
||||
License. You may add Your own attribution notices within Derivative Works that
|
||||
You distribute, alongside or as an addendum to the NOTICE text from the Work,
|
||||
provided that such additional attribution notices cannot be construed as
|
||||
modifying the License.
|
||||
You may add Your own copyright statement to Your modifications and may provide
|
||||
additional or different license terms and conditions for use, reproduction, or
|
||||
distribution of Your modifications, or for any such Derivative Works as a whole,
|
||||
provided Your use, reproduction, and distribution of the Work otherwise complies
|
||||
with the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions.
|
||||
|
||||
Unless You explicitly state otherwise, any Contribution intentionally submitted
|
||||
for inclusion in the Work by You to the Licensor shall be under the terms and
|
||||
conditions of this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify the terms of
|
||||
any separate license agreement you may have executed with Licensor regarding
|
||||
such Contributions.
|
||||
|
||||
6. Trademarks.
|
||||
|
||||
This License does not grant permission to use the trade names, trademarks,
|
||||
service marks, or product names of the Licensor, except as required for
|
||||
reasonable and customary use in describing the origin of the Work and
|
||||
reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty.
|
||||
|
||||
Unless required by applicable law or agreed to in writing, Licensor provides the
|
||||
Work (and each Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
|
||||
including, without limitation, any warranties or conditions of TITLE,
|
||||
NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are
|
||||
solely responsible for determining the appropriateness of using or
|
||||
redistributing the Work and assume any risks associated with Your exercise of
|
||||
permissions under this License.
|
||||
|
||||
8. Limitation of Liability.
|
||||
|
||||
In no event and under no legal theory, whether in tort (including negligence),
|
||||
contract, or otherwise, unless required by applicable law (such as deliberate
|
||||
and grossly negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special, incidental,
|
||||
or consequential damages of any character arising as a result of this License or
|
||||
out of the use or inability to use the Work (including but not limited to
|
||||
damages for loss of goodwill, work stoppage, computer failure or malfunction, or
|
||||
any and all other commercial damages or losses), even if such Contributor has
|
||||
been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability.
|
||||
|
||||
While redistributing the Work or Derivative Works thereof, You may choose to
|
||||
offer, and charge a fee for, acceptance of support, warranty, indemnity, or
|
||||
other liability obligations and/or rights consistent with this License. However,
|
||||
in accepting such obligations, You may act only on Your own behalf and on Your
|
||||
sole responsibility, not on behalf of any other Contributor, and only if You
|
||||
agree to indemnify, defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason of your
|
||||
accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work
|
||||
|
||||
To apply the Apache License to your work, attach the following boilerplate
|
||||
notice, with the fields enclosed by brackets "{}" replaced with your own
|
||||
identifying information. (Don't include the brackets!) The text should be
|
||||
enclosed in the appropriate comment syntax for the file format. We also
|
||||
recommend that a file or class name and description of purpose be included on
|
||||
the same "printed page" as the copyright notice for easier identification within
|
||||
third-party archives.
|
||||
|
||||
Copyright 2018 IT小强xqitw.cn
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
49
vendor/itxq/api-doc-php/README.md
vendored
Normal file
49
vendor/itxq/api-doc-php/README.md
vendored
Normal file
@@ -0,0 +1,49 @@
|
||||
# Api-Doc-PHP
|
||||
|
||||
### 主要功能:
|
||||
|
||||
+ 根据接口注释自动生成接口文档
|
||||
|
||||
### 演示地址
|
||||
|
||||
[【Gitee Pages:】http://itxq.gitee.io/api-doc-php](http://itxq.gitee.io/api-doc-php)
|
||||
|
||||
### 开源地址:
|
||||
|
||||
[【GigHub:】https://github.com/itxq/api-doc-php](https://github.com/itxq/api-doc-php)
|
||||
|
||||
[【码云:】https://gitee.com/itxq/api-doc-php](https://github.com/itxq/api-doc-php)
|
||||
|
||||
### 扩展安装:
|
||||
|
||||
+ 方法一:composer命令 `composer require itxq/api-doc-php`
|
||||
|
||||
+ 方法二:直接下载压缩包,然后进入项目中执行 composer命令 `composer update` 来生成自动加载文件
|
||||
|
||||
### 引用扩展:
|
||||
|
||||
+ 当你的项目不支持composer自动加载时,可以使用以下方式来引用该扩展包
|
||||
|
||||
```
|
||||
// 引入扩展(具体路径请根据你的目录结构自行修改)
|
||||
require_once __DIR__ . '/vendor/autoload.php';
|
||||
```
|
||||
|
||||
### 使用扩展:
|
||||
|
||||
```
|
||||
// 引入扩展(具体路径请根据你的目录结构自行修改)
|
||||
require_once __DIR__ . '/../vendor/autoload.php';
|
||||
// 加载测试API类1
|
||||
require_once __DIR__ . '/Api.php';
|
||||
// 加载测试API类2
|
||||
require_once __DIR__ . '/Api2.php';
|
||||
$config = [
|
||||
'class' => ['Api', 'Api2'], // 要生成文档的类
|
||||
'filter_method' => ['__construct'], // 要过滤的方法名称
|
||||
];
|
||||
$api = new \itxq\apidoc\BootstrapApiDoc($config);
|
||||
$doc = $api->getHtml();
|
||||
exit($doc);
|
||||
```
|
||||
### 具体效果可运行test目录下的`index.php`查看
|
||||
7
vendor/itxq/api-doc-php/assets/css/bootstrap.min.css
vendored
Normal file
7
vendor/itxq/api-doc-php/assets/css/bootstrap.min.css
vendored
Normal file
File diff suppressed because one or more lines are too long
193
vendor/itxq/api-doc-php/assets/index.html
vendored
Normal file
193
vendor/itxq/api-doc-php/assets/index.html
vendored
Normal file
File diff suppressed because one or more lines are too long
7
vendor/itxq/api-doc-php/assets/js/bootstrap.min.js
vendored
Normal file
7
vendor/itxq/api-doc-php/assets/js/bootstrap.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
2
vendor/itxq/api-doc-php/assets/js/jquery.min.js
vendored
Normal file
2
vendor/itxq/api-doc-php/assets/js/jquery.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
20
vendor/itxq/api-doc-php/composer.json
vendored
Normal file
20
vendor/itxq/api-doc-php/composer.json
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"name" : "itxq/api-doc-php",
|
||||
"description": "api-doc-php",
|
||||
"type" : "library",
|
||||
"license" : "Apache-2.0",
|
||||
"authors" : [
|
||||
{
|
||||
"name" : "IT小强xqitw.cn",
|
||||
"email": "360237521@qq.com"
|
||||
}
|
||||
],
|
||||
"require" : {
|
||||
"php": ">=5.6.0"
|
||||
},
|
||||
"autoload" : {
|
||||
"psr-4": {
|
||||
"itxq\\apidoc\\": "src"
|
||||
}
|
||||
}
|
||||
}
|
||||
126
vendor/itxq/api-doc-php/src/ApiDoc.php
vendored
Normal file
126
vendor/itxq/api-doc-php/src/ApiDoc.php
vendored
Normal file
@@ -0,0 +1,126 @@
|
||||
<?php
|
||||
/**
|
||||
* ==================================================================
|
||||
* 文 件 名: ApiDoc.php
|
||||
* 概 要: ApiDoc生成
|
||||
* 作 者: IT小强
|
||||
* 创建时间: 2018/6/5 9:40
|
||||
* 修改时间:
|
||||
* copyright (c) 2016 - 2018 mail@xqitw.cn
|
||||
* ==================================================================
|
||||
*/
|
||||
|
||||
namespace itxq\apidoc;
|
||||
|
||||
use itxq\apidoc\lib\ParseComment;
|
||||
|
||||
/**
|
||||
* ApiDoc生成
|
||||
* Class ApiDoc
|
||||
* @package itxq\apidoc
|
||||
*/
|
||||
class ApiDoc
|
||||
{
|
||||
/**
|
||||
* @var array - 结构化的数组
|
||||
*/
|
||||
private $ApiTree = [];
|
||||
|
||||
/**
|
||||
* @var array - 要生成API的Class类名
|
||||
*/
|
||||
private $class = [];
|
||||
|
||||
/**
|
||||
* @var array - 忽略生成的类方法名
|
||||
*/
|
||||
private $filterMethod = ['__construct'];
|
||||
|
||||
/**
|
||||
* ApiDoc 构造函数.
|
||||
* @param array $config - 配置信息
|
||||
*/
|
||||
public function __construct($config) {
|
||||
// 需要解析的类
|
||||
if (isset($config['class'])) {
|
||||
$this->class = array_merge($this->class, $config['class']);
|
||||
}
|
||||
// 忽略生成的类方法
|
||||
if (isset($config['filter_method'])) {
|
||||
$this->filterMethod = array_merge($this->filterMethod, $config['filter_method']);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取API文档数据
|
||||
* @param int $type - 方法过滤,默认只获取 public类型 方法
|
||||
* ReflectionMethod::IS_STATIC
|
||||
* ReflectionMethod::IS_PUBLIC
|
||||
* ReflectionMethod::IS_PROTECTED
|
||||
* ReflectionMethod::IS_PRIVATE
|
||||
* ReflectionMethod::IS_ABSTRACT
|
||||
* ReflectionMethod::IS_FINAL
|
||||
* @return array
|
||||
*/
|
||||
public function getApiDoc($type = \ReflectionMethod::IS_PUBLIC) {
|
||||
foreach ($this->class as $classItem) {
|
||||
$actionInfo = $this->_getActionComment($classItem, $type);
|
||||
if (count($actionInfo) >= 1) {
|
||||
$this->ApiTree[$classItem] = $this->_getClassComment($classItem);
|
||||
$this->ApiTree[$classItem]['action'] = $actionInfo;
|
||||
}
|
||||
}
|
||||
return $this->ApiTree;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取类的注释
|
||||
* @param $class - 类名称(存在命名空间时要完整写入) eg: $class = 'itxq\\apidoc\\ApiDoc';
|
||||
* @return array - 返回格式为数组(未获取到注释时返回空数组)
|
||||
*/
|
||||
private function _getClassComment($class) {
|
||||
try {
|
||||
$reflection = new \ReflectionClass($class);
|
||||
$classDocComment = $reflection->getDocComment();
|
||||
} catch (\Exception $exception) {
|
||||
return [];
|
||||
}
|
||||
$parse = new ParseComment();
|
||||
return $parse->parseCommentToArray($classDocComment);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取指定类下方法的注释
|
||||
* @param $class - 类名称(存在命名空间时要完整写入) eg: $class = 'itxq\\apidoc\\ApiDoc';
|
||||
* @param int $type - 方法过滤,默认只获取 public类型 方法
|
||||
* ReflectionMethod::IS_STATIC
|
||||
* ReflectionMethod::IS_PUBLIC
|
||||
* ReflectionMethod::IS_PROTECTED
|
||||
* ReflectionMethod::IS_PRIVATE
|
||||
* ReflectionMethod::IS_ABSTRACT
|
||||
* ReflectionMethod::IS_FINAL
|
||||
* @return array - 返回格式为数组(未获取到注释时返回空数组)
|
||||
*/
|
||||
private function _getActionComment($class, $type = \ReflectionMethod::IS_PUBLIC) {
|
||||
try {
|
||||
$reflection = new \ReflectionClass($class);
|
||||
//只允许生成public方法
|
||||
$method = $reflection->getMethods($type);
|
||||
} catch (\Exception $exception) {
|
||||
return [];
|
||||
}
|
||||
$comments = [];
|
||||
foreach ($method as $action) {
|
||||
try {
|
||||
$parse = new ParseComment();
|
||||
$actionComments = $parse->parseCommentToArray($action->getDocComment());
|
||||
if (count($actionComments) >= 1 && !in_array($action->name, $this->filterMethod)) {
|
||||
$comments[$action->name] = $actionComments;
|
||||
}
|
||||
} catch (\Exception $exception) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
return $comments;
|
||||
}
|
||||
}
|
||||
357
vendor/itxq/api-doc-php/src/BootstrapApiDoc.php
vendored
Normal file
357
vendor/itxq/api-doc-php/src/BootstrapApiDoc.php
vendored
Normal file
@@ -0,0 +1,357 @@
|
||||
<?php
|
||||
/**
|
||||
* ==================================================================
|
||||
* 文 件 名: BootstrapApiDoc.php
|
||||
* 概 要: BootstrapAPI文档生成
|
||||
* 作 者: IT小强
|
||||
* 创建时间: 2018/6/6 13:57
|
||||
* 修改时间:
|
||||
* copyright (c) 2016 - 2018 mail@xqitw.cn
|
||||
* ==================================================================
|
||||
*/
|
||||
|
||||
namespace itxq\apidoc;
|
||||
|
||||
use itxq\apidoc\lib\Tools;
|
||||
|
||||
/**
|
||||
* BootstrapAPI文档生成
|
||||
* Class BootstrapApiDoc
|
||||
* @package itxq\apidoc
|
||||
*/
|
||||
class BootstrapApiDoc extends ApiDoc
|
||||
{
|
||||
/**
|
||||
* @var string - Bootstrap CSS文件路径
|
||||
*/
|
||||
private $bootstrapCss = __DIR__ . '/../assets/css/bootstrap.min.css';
|
||||
|
||||
/**
|
||||
* @var string - Bootstrap JS文件路径
|
||||
*/
|
||||
private $bootstrapJs = __DIR__ . '/../assets/js/bootstrap.min.js';
|
||||
|
||||
/**
|
||||
* @var string - jQuery Js文件路径
|
||||
*/
|
||||
private $jQueryJs = __DIR__ . '/../assets/js/jquery.min.js';
|
||||
|
||||
/**
|
||||
* @var string - 自定义CSS
|
||||
*/
|
||||
private $customCss = '<style type="text/css">
|
||||
::-webkit-scrollbar {width: 5px;}
|
||||
.navbar-collapse.collapse.show::-webkit-scrollbar {width: 0; height: 0;background-color: rgba(255, 255, 255, 0);}
|
||||
::-webkit-scrollbar-track {background-color: rgba(255, 255, 255, 0.2);-webkit-border-radius: 2em;-moz-border-radius: 2em;border-radius: 2em;}
|
||||
::-webkit-scrollbar-thumb {background-color: rgba(0, 0, 0, 0.8);-webkit-border-radius: 2em;-moz-border-radius: 2em;border-radius: 2em;}
|
||||
::-webkit-scrollbar-button {-webkit-border-radius: 2em;-moz-border-radius: 2em;border-radius: 2em;height: 0;background-color: rgba(0, 0, 0, 0.9);}
|
||||
::-webkit-scrollbar-corner {background-color: rgba(0, 0, 0, 0.9);}
|
||||
#list-tab-left-nav{display: none;}
|
||||
.doc-content{margin-top: 75px;}
|
||||
.class-item .class-title {text-indent: 0.6em;border-left: 5px solid lightseagreen;font-size: 24px;margin: 15px 0;}
|
||||
.action-item .action-title {text-indent: 0.6em;border-left: 3px solid #F0AD4E;font-size: 20px;margin: 8px 0;}
|
||||
.table-item {background-color:#FFFFFF;padding-top: 10px;margin-bottom:10px;border: solid 1px #ccc;border-radius: 5px;}
|
||||
.list-group-item-sub{padding: .5rem 1.25rem;}
|
||||
.copyright-content{margin: 10px 0;}
|
||||
</style>';
|
||||
|
||||
/**
|
||||
* @var string - 自定义JS
|
||||
*/
|
||||
private $customJs = '<script type="text/javascript">
|
||||
$(\'a[href*="#"]:not([href="#"])\').click(function() {
|
||||
if (location.pathname.replace(/^\//, \'\') == this.pathname.replace(/^\//, \'\') && location.hostname == this.hostname) {
|
||||
var target = $(this.hash);
|
||||
target = target.length ? target : $("[name=\' + this.hash.slice(1) +\']");
|
||||
if (target.length) {
|
||||
var topOffset = target.offset().top - 60;
|
||||
$("html, body").animate({
|
||||
scrollTop: topOffset
|
||||
}, 800);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>';
|
||||
|
||||
/**
|
||||
* Bootstrap 构造函数.
|
||||
* @param array $config - 配置信息
|
||||
*/
|
||||
public function __construct($config) {
|
||||
parent::__construct($config);
|
||||
// bootstrapJs文件路径
|
||||
$this->bootstrapJs = Tools::getSubValue('bootstrap_js', $config, $this->bootstrapJs);
|
||||
// jQueryJs文件路径
|
||||
$this->jQueryJs = Tools::getSubValue('jquery_js', $config, $this->jQueryJs);
|
||||
// 自定义js
|
||||
$this->customJs .= Tools::getSubValue('custom_js', $config, '');
|
||||
// bootstrapCSS文件路径
|
||||
$this->bootstrapCss = Tools::getSubValue('bootstrap_css', $config, $this->bootstrapCss);
|
||||
// 自定义CSS
|
||||
$this->customCss .= Tools::getSubValue('custom_css', $config, '');
|
||||
// 合并CSS
|
||||
$this->_getCss();
|
||||
// 合并JS
|
||||
$this->_getJs();
|
||||
}
|
||||
|
||||
/**
|
||||
* 输出HTML
|
||||
* @param int $type - 方法过滤,默认只获取 public类型 方法
|
||||
* ReflectionMethod::IS_STATIC
|
||||
* ReflectionMethod::IS_PUBLIC
|
||||
* ReflectionMethod::IS_PROTECTED
|
||||
* ReflectionMethod::IS_PRIVATE
|
||||
* ReflectionMethod::IS_ABSTRACT
|
||||
* ReflectionMethod::IS_FINAL
|
||||
* @return string
|
||||
*/
|
||||
public function getHtml($type = \ReflectionMethod::IS_PUBLIC) {
|
||||
$data = $this->getApiDoc($type);
|
||||
$html = <<<EXT
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="renderer" content="webkit">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">
|
||||
<!-- 禁止浏览器初始缩放 -->
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no, maximum-scale=1, user-scalable=0">
|
||||
<title>API文档 By Api-Doc-PHP</title>
|
||||
{$this->customCss}
|
||||
</head>
|
||||
<body>
|
||||
<div class="container-fluid">
|
||||
<nav class="navbar navbar-expand-sm navbar-dark bg-dark fixed-top">
|
||||
<a class="navbar-brand" href="#">API文档</a>
|
||||
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarColor01" >
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
</button>
|
||||
<div class="collapse navbar-collapse" id="navbarColor01">
|
||||
{$this->_getTopNavList($data)}
|
||||
</div>
|
||||
</nav>
|
||||
<div class="row">
|
||||
<div class="col-lg-12">{$this->_getDocList($data)}</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-lg-12 text-center copyright-content">
|
||||
Copyright 2016 - 2018 <a href="http://www.xqitw.cn">小强IT屋</a> 版权所有
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{$this->customJs}
|
||||
</body>
|
||||
</html>
|
||||
EXT;
|
||||
|
||||
if (isset($_GET['download']) && $_GET['download'] === 'api_doc_php') {
|
||||
Tools::downloadFile($html);
|
||||
return true;
|
||||
}
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析return 并生成HTML
|
||||
* @param array $data
|
||||
* @return string
|
||||
*/
|
||||
private function _getReturnData($data = []) {
|
||||
$html = '';
|
||||
if (!is_array($data) || count($data) < 1) {
|
||||
return $html;
|
||||
}
|
||||
$html .= '<div class="table-item col-md-12"><p class="table-title"><span class="btn btn-sm btn-success">返回参数</span></p>';
|
||||
$html .= '<table class="table"><tr><td>参数</td><td>类型</td><td>描述</td></tr>';
|
||||
foreach ($data as $v) {
|
||||
$html .= '<tr>
|
||||
<td>' . Tools::getSubValue('return_name', $v, '') . '</td>
|
||||
<td>' . Tools::getSubValue('return_type', $v, '') . '</td>
|
||||
<td>' . Tools::getSubValue('return_title', $v, '') . '</td>
|
||||
</tr>';
|
||||
}
|
||||
$html .= '</table></div>';
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析param 并生成HTML
|
||||
* @param array $data
|
||||
* @return string
|
||||
*/
|
||||
private function _getParamData($data = []) {
|
||||
$html = '';
|
||||
if (!is_array($data) || count($data) < 1) {
|
||||
return $html;
|
||||
}
|
||||
$html .= '<div class="table-item col-md-12"><p class="table-title"><span class="btn btn-sm btn-danger">请求参数</span></p>';
|
||||
$html .= '<table class="table"><tr><td>参数</td><td>类型</td><td>描述</td><td>默认值</td><td>是否必须</td></tr>';
|
||||
foreach ($data as $v) {
|
||||
$html .= '<tr>
|
||||
<td>' . Tools::getSubValue('param_name', $v, '') . '</td>
|
||||
<td>' . Tools::getSubValue('param_type', $v, '') . '</td>
|
||||
<td>' . Tools::getSubValue('param_title', $v, '') . '</td>
|
||||
<td>' . Tools::getSubValue('param_default', $v, '无默认值') . '</td>
|
||||
<td>' . Tools::getSubValue('param_require', $v, '非必须') . '</td>
|
||||
</tr>';
|
||||
}
|
||||
$html .= '</table></div>';
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析code 并生成HTML
|
||||
* @param array $data
|
||||
* @return string
|
||||
*/
|
||||
private function _getCodeData($data = []) {
|
||||
$html = '';
|
||||
if (!is_array($data) || count($data) < 1) {
|
||||
return $html;
|
||||
}
|
||||
$html .= '<div class="table-item col-md-12"><p class="table-title"><span class="btn btn-sm btn-warning">状态码说明</span></p>';
|
||||
$html .= '<table class="table"><tr><td>状态码</td><td>描述</td></tr>';
|
||||
foreach ($data as $v) {
|
||||
$html .= '<tr>
|
||||
<td>' . Tools::getSubValue('code', $v, '') . '</td>
|
||||
<td>' . Tools::getSubValue('content', $v, '暂无说明') . '</td>
|
||||
</tr>';
|
||||
}
|
||||
$html .= '</table></div>';
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取指定接口操作下的文档信息
|
||||
* @param $className - 类名
|
||||
* @param $actionName - 操作名
|
||||
* @param $actionItem - 接口数据
|
||||
* @return string
|
||||
*/
|
||||
private function _getActionItem($className, $actionName, $actionItem) {
|
||||
$html = <<<EXT
|
||||
<div class="list-group-item list-group-item-action action-item col-md-12" id="{$className}_{$actionName}">
|
||||
<h4 class="action-title">API - {$actionItem['title']}</h4>
|
||||
<p>请求方式:
|
||||
<span class="btn btn-info btn-sm">{$actionItem['method']}</span>
|
||||
</p>
|
||||
<p>请求地址:<a href="{$actionItem['url']}">{$actionItem['url']}</a></p>
|
||||
{$this->_getParamData(Tools::getSubValue('param', $actionItem, []))}
|
||||
{$this->_getReturnData(Tools::getSubValue('return', $actionItem, []))}
|
||||
{$this->_getCodeData(Tools::getSubValue('code', $actionItem, []))}
|
||||
</div>
|
||||
EXT;
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取指定API类的文档HTML
|
||||
* @param $className - 类名称
|
||||
* @param $classItem - 类数据
|
||||
* @return string
|
||||
*/
|
||||
private function _getClassItem($className, $classItem) {
|
||||
$title = Tools::getSubValue('title', $classItem, '未命名');
|
||||
$actionHtml = '';
|
||||
if (isset($classItem['action']) && is_array($classItem['action']) && count($classItem['action']) >= 1) {
|
||||
foreach ($classItem['action'] as $actionName => $actionItem) {
|
||||
$actionHtml .= $this->_getActionItem($className, $actionName, $actionItem);
|
||||
}
|
||||
}
|
||||
$html = <<<EXT
|
||||
<div class="class-item" id="{$className}">
|
||||
<h2 class="class-title">{$title}</h2>
|
||||
<div class="list-group">{$actionHtml}</div>
|
||||
</div>
|
||||
EXT;
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取API文档HTML
|
||||
* @param array $data - 文档数据
|
||||
* @return string
|
||||
*/
|
||||
private function _getDocList($data) {
|
||||
$html = '';
|
||||
if (count($data) < 1) {
|
||||
return $html;
|
||||
}
|
||||
$html .= '<div class="doc-content">';
|
||||
foreach ($data as $className => $classItem) {
|
||||
$html .= $this->_getClassItem($className, $classItem);
|
||||
}
|
||||
$html .= '</div>';
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取顶部导航HTML
|
||||
* @param $data -API文档数据
|
||||
* @return string
|
||||
*/
|
||||
private function _getTopNavList($data) {
|
||||
$html = '<ul class="navbar-nav" id="navbar-nav-top-nav">';
|
||||
foreach ($data as $className => $classItem) {
|
||||
$title = Tools::getSubValue('title', $classItem, '未命名');
|
||||
$html .= '<li class="nav-item dropdown">';
|
||||
$html .= '<a class="nav-link dropdown-toggle" href="#" id="' . $className . '-nav" data-toggle="dropdown">' . $title . '</a>';
|
||||
$html .= '<div class="dropdown-menu" aria-labelledby="' . $className . '-nav">';
|
||||
foreach ($classItem['action'] as $actionName => $actionItem) {
|
||||
$title = Tools::getSubValue('title', $actionItem, '未命名');
|
||||
$id = $className . '_' . $actionName;
|
||||
$html .= '<a class="dropdown-item" href="#' . $id . '">' . $title . '</a>';
|
||||
}
|
||||
$html .= '</div></li>';
|
||||
}
|
||||
$html .= ' <li class="nav-item"><a class="nav-link" href="?download=api_doc_php">下载文档</a></li>';
|
||||
$html .= '</ul>';
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取文档CSS
|
||||
* @return string
|
||||
*/
|
||||
private function _getCss() {
|
||||
$path = realpath($this->bootstrapCss);
|
||||
if (!$path || !is_file($path)) {
|
||||
return $this->customCss;
|
||||
}
|
||||
$bootstrapCss = file_get_contents($path);
|
||||
if (empty($bootstrapCss)) {
|
||||
return $this->customCss;
|
||||
}
|
||||
$this->customCss = '<style type="text/css">' . $bootstrapCss . '</style>' . $this->customCss;
|
||||
// $this->customCss = ' <link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" rel="stylesheet">' . $this->customCss;
|
||||
return $this->customCss;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取文档JS
|
||||
* @return string
|
||||
*/
|
||||
private function _getJs() {
|
||||
// $js = '<script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.min.js" type="text/javascript"></script>';
|
||||
// $js .= '<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.min.js" type="text/javascript"></script>';
|
||||
// $this->customJs = $js . $this->customJs;
|
||||
// return $this->customJs;
|
||||
$bootstrapJs = realpath($this->bootstrapJs);
|
||||
$jQueryJs = realpath($this->jQueryJs);
|
||||
if (!$bootstrapJs || !$jQueryJs || !is_file($bootstrapJs) || !is_file($jQueryJs)) {
|
||||
$this->customJs = '';
|
||||
return $this->customCss;
|
||||
}
|
||||
$bootstrapJs = file_get_contents($bootstrapJs);
|
||||
$jQueryJs = file_get_contents($jQueryJs);
|
||||
if (empty($bootstrapJs) || empty($jQueryJs)) {
|
||||
$this->customJs = '';
|
||||
return $this->customJs;
|
||||
}
|
||||
$js = '<script type="text/javascript">' . $jQueryJs . '</script>' . '<script type="text/javascript">' . $bootstrapJs . '</script>';
|
||||
$this->customJs = $js . $this->customJs;
|
||||
return $this->customJs;
|
||||
}
|
||||
}
|
||||
87
vendor/itxq/api-doc-php/src/lib/ParseComment.php
vendored
Normal file
87
vendor/itxq/api-doc-php/src/lib/ParseComment.php
vendored
Normal file
@@ -0,0 +1,87 @@
|
||||
<?php
|
||||
/**
|
||||
* ==================================================================
|
||||
* 文 件 名: ParseComment.php
|
||||
* 概 要: 注释解析
|
||||
* 作 者: IT小强
|
||||
* 创建时间: 2018/6/5 10:38
|
||||
* 修改时间:
|
||||
* copyright (c) 2016 - 2018 mail@xqitw.cn
|
||||
* ==================================================================
|
||||
*/
|
||||
|
||||
namespace itxq\apidoc\lib;
|
||||
|
||||
/**
|
||||
* 注释解析
|
||||
* Class ParseComment
|
||||
* @package itxq\apidoc\lib
|
||||
*/
|
||||
class ParseComment
|
||||
{
|
||||
/**
|
||||
* @var array - 注释解析后的数组
|
||||
*/
|
||||
private $commentParams = [];
|
||||
|
||||
/**
|
||||
* 将注释按行解析并以数组格式返回
|
||||
* @param $comment - 原始注释字符串
|
||||
* @return bool|array
|
||||
*/
|
||||
public function parseCommentToArray($comment) {
|
||||
$comments = [];
|
||||
if (empty($comment)) {
|
||||
return $comments;
|
||||
}
|
||||
// 获取注释
|
||||
if (preg_match('#^/\*\*(.*)\*/#s', $comment, $matches) === false) {
|
||||
return $comments;
|
||||
}
|
||||
$matches = trim($matches[1]);
|
||||
// 按行分割注释
|
||||
if (preg_match_all('#^\s*\*(.*)#m', $matches, $lines) === false) {
|
||||
return $comments;
|
||||
}
|
||||
$comments = $lines[1];
|
||||
// 去除无用的注释
|
||||
foreach ($comments as $k => $v) {
|
||||
$comments[$k] = $v = trim($v);
|
||||
if (strpos($v, '@') !== 0) {
|
||||
continue;
|
||||
}
|
||||
$_parse = $this->_parseCommentLine($v);
|
||||
if (!$_parse) {
|
||||
continue;
|
||||
}
|
||||
$_type = $_parse['type'];
|
||||
$_content = isset($_parse['content']) ? $_parse['content'] : '';
|
||||
if (in_array($_type, ['param', 'code', 'return'])) {
|
||||
if (!isset($this->commentParams[$_type])) {
|
||||
$this->commentParams[$_type] = [];
|
||||
}
|
||||
unset($_parse['type']);
|
||||
$this->commentParams[$_type][] = $_parse;
|
||||
} else {
|
||||
$this->commentParams[$_type] = $_content;
|
||||
}
|
||||
}
|
||||
return $this->commentParams;
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析注释中的参数
|
||||
* @param $line - 注释行
|
||||
* @return bool|array - 解析后的数组(解析失败返回false)
|
||||
*/
|
||||
private function _parseCommentLine($line) {
|
||||
$line = explode(' ', $line);
|
||||
$line[0] = substr($line[0], 1);
|
||||
$class = new ParseLine();
|
||||
$action = 'parseLine' . Tools::underlineToHump($line[0]);
|
||||
if (!method_exists($class, $action)) {
|
||||
$action = 'parseLineTitle';
|
||||
}
|
||||
return $class->$action($line);
|
||||
}
|
||||
}
|
||||
73
vendor/itxq/api-doc-php/src/lib/ParseLine.php
vendored
Normal file
73
vendor/itxq/api-doc-php/src/lib/ParseLine.php
vendored
Normal file
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
/**
|
||||
* ==================================================================
|
||||
* 文 件 名: ParseLine.php
|
||||
* 概 要: 按行解析注释参数
|
||||
* 作 者: IT小强
|
||||
* 创建时间: 2018/6/5 10:34
|
||||
* 修改时间:
|
||||
* copyright (c) 2016 - 2018 mail@xqitw.cn
|
||||
* ==================================================================
|
||||
*/
|
||||
|
||||
namespace itxq\apidoc\lib;
|
||||
|
||||
/**
|
||||
* 按行解析注释参数
|
||||
* Class ParseLine
|
||||
* @package itxq\apidoc\lib
|
||||
*/
|
||||
class ParseLine
|
||||
{
|
||||
/**
|
||||
* 解析 title|url
|
||||
* @param $line
|
||||
* @return array
|
||||
*/
|
||||
public function parseLineTitle($line) {
|
||||
return ['type' => isset($line[0]) ? $line[0] : '', 'content' => isset($line[1]) ? $line[1] : ''];
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析 param
|
||||
* @param $line
|
||||
* @return array
|
||||
*/
|
||||
public function parseLineParam($line) {
|
||||
return [
|
||||
'type' => isset($line[0]) ? $line[0] : '',
|
||||
'param_type' => isset($line[1]) ? $line[1] : '',
|
||||
'param_name' => isset($line[2]) ? $line[2] : '',
|
||||
'param_title' => isset($line[3]) ? $line[3] : '',
|
||||
'param_default' => isset($line[4]) ? $line[4] : '',
|
||||
'param_require' => isset($line[5]) ? $line[5] : '',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析 code
|
||||
* @param $line
|
||||
* @return array
|
||||
*/
|
||||
public function parseLineCode($line) {
|
||||
return [
|
||||
'type' => isset($line[0]) ? $line[0] : '',
|
||||
'code' => isset($line[1]) ? $line[1] : '',
|
||||
'content' => isset($line[2]) ? $line[2] : '',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析 return
|
||||
* @param $line
|
||||
* @return array
|
||||
*/
|
||||
public function parseLineReturn($line) {
|
||||
return [
|
||||
'type' => isset($line[0]) ? $line[0] : '',
|
||||
'return_type' => isset($line[1]) ? $line[1] : '',
|
||||
'return_name' => isset($line[2]) ? $line[2] : '',
|
||||
'return_title' => isset($line[3]) ? $line[3] : '',
|
||||
];
|
||||
}
|
||||
}
|
||||
82
vendor/itxq/api-doc-php/src/lib/Tools.php
vendored
Normal file
82
vendor/itxq/api-doc-php/src/lib/Tools.php
vendored
Normal file
@@ -0,0 +1,82 @@
|
||||
<?php
|
||||
/**
|
||||
* ==================================================================
|
||||
* 文 件 名: Tools.php
|
||||
* 概 要:
|
||||
* 作 者: IT小强
|
||||
* 创建时间: 2018/6/6 8:47
|
||||
* 修改时间:
|
||||
* copyright (c) 2016 - 2018 mail@xqitw.cn
|
||||
* ==================================================================
|
||||
*/
|
||||
|
||||
namespace itxq\apidoc\lib;
|
||||
|
||||
/**
|
||||
* 工具类
|
||||
* Class Tools
|
||||
* @package itxq\apidoc\lib
|
||||
*/
|
||||
class Tools
|
||||
{
|
||||
/**
|
||||
* 下划线命名转驼峰命名
|
||||
* @param $str - 下划线命名字符串
|
||||
* @param $isFirst - 是否为大驼峰(即首字母也大写)
|
||||
* @return mixed
|
||||
*/
|
||||
public static function underlineToHump($str, $isFirst = false) {
|
||||
$str = preg_replace_callback('/([\-\_]+([a-z]{1}))/i', function ($matches) {
|
||||
return strtoupper($matches[2]);
|
||||
}, $str);
|
||||
if ($isFirst) {
|
||||
$str = ucfirst($str);
|
||||
}
|
||||
return $str;
|
||||
}
|
||||
|
||||
/**
|
||||
* 驼峰命名转下划线命名
|
||||
* @param $str
|
||||
* @return mixed
|
||||
*/
|
||||
public static function humpToUnderline($str) {
|
||||
$str = preg_replace_callback('/([A-Z]{1})/', function ($matches) {
|
||||
return '_' . strtolower($matches[0]);
|
||||
}, $str);
|
||||
$str = preg_replace('/^\_/', '', $str);
|
||||
return $str;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取数组、对象下标对应值,不存在时返回指定的默认值
|
||||
* @param string|integer $name - 下标(键名)
|
||||
* @param array|object $data - 原始数组/对象
|
||||
* @param mixed $default - 指定默认值
|
||||
* @return mixed
|
||||
*/
|
||||
public static function getSubValue($name, $data, $default = '') {
|
||||
if (is_object($data)) {
|
||||
$value = isset($data->$name) ? $data->$name : $default;
|
||||
} else if (is_array($data)) {
|
||||
$value = isset($data[$name]) ? $data[$name] : $default;
|
||||
} else {
|
||||
$value = $default;
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* 文件下载
|
||||
* @param string - $docHtml - API文档HTML内容
|
||||
*/
|
||||
public static function downloadFile($docHtml) {
|
||||
set_time_limit(0);
|
||||
//下载文件需要用到的头
|
||||
header('Content-type: application/octet-stream');
|
||||
header('Accept-Ranges: bytes');
|
||||
header('Content-Disposition: attachment; filename=api-doc_' . date('Y-m-d') . '.html');
|
||||
echo $docHtml;
|
||||
exit();
|
||||
}
|
||||
}
|
||||
49
vendor/itxq/api-doc-php/test/Api.php
vendored
Normal file
49
vendor/itxq/api-doc-php/test/Api.php
vendored
Normal file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
/**
|
||||
* ==================================================================
|
||||
* 文 件 名: Api.php
|
||||
* 概 要:
|
||||
* 作 者: IT小强
|
||||
* 创建时间: 2018/6/5 9:43
|
||||
* 修改时间:
|
||||
* copyright (c) 2016 - 2018 mail@xqitw.cn
|
||||
* ==================================================================
|
||||
*/
|
||||
|
||||
/**
|
||||
* @title 登录注册
|
||||
* Class Api
|
||||
*/
|
||||
class Api
|
||||
{
|
||||
/**
|
||||
* @title 用户登录API
|
||||
* @url https://wwww.baidu.com/login
|
||||
* @method POST
|
||||
* @param string username 账号 空 必须
|
||||
* @param string password 密码 空 必须
|
||||
* @code 1 成功
|
||||
* @code 2 失败
|
||||
* @return int code 状态码(具体参见状态码说明)
|
||||
* @return string msg 提示信息
|
||||
*/
|
||||
public function login() {
|
||||
return json_encode(['code' => 1, 'msg' => '登录成功']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @title 用户注册API
|
||||
* @url https://wwww.baidu.com/reg
|
||||
* @method POST
|
||||
* @param string username 账号 空 必须
|
||||
* @param string password 密码 空 必须
|
||||
* @param string password2 重复密码 空 必须
|
||||
* @code 1 成功
|
||||
* @code 2 失败
|
||||
* @return int code 状态码(具体参见状态码说明)
|
||||
* @return string msg 提示信息
|
||||
*/
|
||||
public function reg() {
|
||||
return json_encode(['code' => 1, 'msg' => '注册成功']);
|
||||
}
|
||||
}
|
||||
33
vendor/itxq/api-doc-php/test/Api2.php
vendored
Normal file
33
vendor/itxq/api-doc-php/test/Api2.php
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
/**
|
||||
* ==================================================================
|
||||
* 文 件 名: Api2.php
|
||||
* 概 要:
|
||||
* 作 者: IT小强
|
||||
* 创建时间: 2018/6/6 9:17
|
||||
* 修改时间:
|
||||
* copyright (c) 2016 - 2018 mail@xqitw.cn
|
||||
* ==================================================================
|
||||
*/
|
||||
|
||||
/**
|
||||
* @title 用户相关
|
||||
* Class Api
|
||||
*/
|
||||
class Api2
|
||||
{
|
||||
/**
|
||||
* @title 获取用户信息
|
||||
* @url https://wwww.baidu.com/getuserinfo
|
||||
* @method GET
|
||||
* @param int uid 用户ID 0 必须
|
||||
* @param string token 令牌 空 必须
|
||||
* @code 1 成功
|
||||
* @code 2 失败
|
||||
* @return int code 状态码(具体参见状态码说明)
|
||||
* @return string msg 提示信息
|
||||
*/
|
||||
public function getUserInfo() {
|
||||
return json_encode(['code' => 1, 'msg' => '获取信息成功', 'data' => ['uid' => 1, 'username' => 'admin']]);
|
||||
}
|
||||
}
|
||||
22
vendor/itxq/api-doc-php/test/index.php
vendored
Normal file
22
vendor/itxq/api-doc-php/test/index.php
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
/**
|
||||
* ==================================================================
|
||||
* 文 件 名: index.php
|
||||
* 概 要: API文档 By Api-Doc-PHP
|
||||
* 作 者: IT小强
|
||||
* 创建时间: 2018/6/5 9:48
|
||||
* 修改时间:
|
||||
* copyright (c) 2016 - 2018 mail@xqitw.cn
|
||||
* ==================================================================
|
||||
*/
|
||||
require_once __DIR__ . '/../vendor/autoload.php';
|
||||
require_once __DIR__ . '/Api.php'; // 加载测试API类1
|
||||
require_once __DIR__ . '/Api2.php'; // 加载测试API类2
|
||||
$config = [
|
||||
'class' => ['Api', 'Api2'], // 要生成文档的类
|
||||
'filter_method' => ['__construct'], // 要过滤的方法名称
|
||||
];
|
||||
$api = new \itxq\apidoc\BootstrapApiDoc($config);
|
||||
$doc = $api->getHtml();
|
||||
exit($doc);
|
||||
|
||||
Reference in New Issue
Block a user