PHP code example of oyhdd / laravel-apidoc
1. Go to this page and download the library: Download oyhdd/laravel-apidoc 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/ */
oyhdd / laravel-apidoc example snippets
php artisan vendor:publish --provider="Oyhdd\Document\DocumentServiceProvider"
php artisan vendor:publish --provider="Oyhdd\Document\DocumentServiceProvider" --force
php artisan migrate --path=./vendor/oyhdd/laravel-apidoc/src/database/migrations/
java
/**
* @name 测试1
* @uses 测试接口
* @author wangmeng
* @date 2018-10-19
* @header string|true $token header头
* @param string|true $str 字符串
* @param int|true $number 数字
* @param array|true $arr 数组
* @return array
*/
public function test(Request $request)
{
$ret = [
'code' => 0,
'msg' => 'success',
'data' => [
'header' => ['token' => $request->header('token')],
'body' => $request->all(),
],
];
return $ret;
}
java
//测试示例接口
Route::group([], function ($router) {
// 接口组
$router->name('测试.')->group(function ($router) {
$router->post('test', 'Oyhdd\Document\Controllers\TestController@test');
});
});
java
return [
// 路由分组的分隔符
'delimiter' => '.',
// 不需展示的接口路由
'hiddenMethods' => [
// Controller::class
'App\Http\Controllers\TestController' => [
'test',//该Controller下的此action
'*',//该Controller下的所有action
],
],
// 是否显示未配置路由的接口
'showUndefinedRouter' => false,
];