PHP code example of weiwei2012holy / eolinker-doc
1. Go to this page and download the library: Download weiwei2012holy/eolinker-doc library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
weiwei2012holy / eolinker-doc example snippets
/**
* @api {get} api/home
* @apiName 测试首页
* @apiStatus todo
* @apiDescription 测试描述
* @apiVersion 1.0.0
* @apiPermission token
* @apiParam {integer} user_id 用户id
* @apiSuccess {object} data={\App\WxaUser}
* @apiSuccess {integer} data.new_name 名称
*/
public function home()
{
$data = WxaUser::query()->first();
$data->new_name = 'new name';
return $data;
}
# 路由文件定义
Route::get('test', 'HomeController@home')->name('测试应用.测试模块.测试doc-composer');
# 模型自定义字段,支持数组
public function getTableFullColumnsCustom(): array
{
return [
'test'=>'test',
'test2'=>'test2',
'test_arr'=>[
'test_aaa'=>'test_aaa',
'test_bbb'=>'test_bbb',
'test_ccc'=>[
'test_c1'=>111,
'test_c2'=>222,
]
]
];
}
* @apiSuccess {object[]} data={\App\Models\WxaMallLiving\WxaLivingComment} 评论数据
* @apiParam {object[]} data={\App\Models\WxaMallLiving\WxBadWord}
shell
$ composer
php artisan vendor:publish --provider="Weiwei2012holy\EolinkerDoc\ServiceProvider"
# 配置eolikner数据库链接
database.php
----
'eolinker' => [
'driver' => 'mysql',
'host' => env('DB_EOLINKER_HOST'),
'port' => env('DB_EOLINKER_PORT', '3306'),
'database' => env('DB_EOLINKER_DATABASE', 'eolikner_os'),
'username' => env('DB_EOLINKER_USERNAME'),
'password' => env('DB_EOLINKER_PASSWORD'),
'unix_socket' => env('DB_EOLINKER_SOCKET', ''),
'charset' => 'utf8mb4',
'collation' => 'utf8mb4_general_ci',
'prefix' => '',
'strict' => true,
'engine' => null,
],
----
.env 文件,记得绑定host
----
#eolikner
DB_EOLINKER_CONNECTION=eolinker
DB_EOLINKER_HOST=mysql.test.wxyk
DB_EOLINKER_HOST_READ=mysql.test.wxyk
DB_EOLINKER_PORT=3306
DB_EOLINKER_DATABASE=eolinker_os
DB_EOLINKER_USERNAME=yk_db
DB_EOLINKER_PASSWORD=rIit6vG15z63QJqT
----
# 修改配置eolikner.php 配置默认账号和生成的文档项目id
# 运行接口生成工具
php artisan eolinker:create-doc
bash
#创建api接口文档到eolikner
php artisan eolinker:create-doc