用于查看和测试后端REST接口
laravel >= 5.1,php > 7
composer require deathkel/apitest
请到注册服务提供者到Laravel服务提供者列表中。 方法1: 在config/app.php配置文件中,key为'providers'的数组中添加服务提供者
'providers'=>[
//...
Deathkel\Apitest\ApiTestServiceProvider::class
]
运行 'php artisan vendor:publish'将视图文件和静态文件发布到你们的项目中,请确保文件夹resource/views/api和public/api文件夹为空。 否则请自行复制使用本项目frotend文件中的blade和静态文件
请配置在debug模式开启下的路由,不要再生产环境中使用
if (config('app.debug')) {
Route::get('apitest','ApiTestController@index');
}
use Deathkel\Apitest\ApiReflection;
class ApiTestController extend Controller{
public function index(){
$reflection=new ApiReflection();
$api=$reflection->getApi();
$apiToString=json_encode($api);
return view('api.index', ['api' => $api,'apiToString'=>$apiToString]);
}
}
private function config(){
return [
'App\Http\Controllers\IndexController',
'App\Http\Controllers\HomeController',
];
}
.....
$reflection=new ApiReflection();
$reflection->setConfig($this->config());
$api=$reflection->getApi();
.....
- 添加了该参数才能使用该工具的其他功能。否则注释只能以文本格式展示(可用于兼容老的注释)
- 参数格式:自定义参数的格式名称。如(int|string|可选)等等
- 参数名称:查询参数的名称。如name,title等等
- 简单说明:随意写点吧
注意用一个
空格
分割
- 如
author
version
...
注意名称和说明之间用一个
空格
分割
/**
* @apiTest
* @param nullable|int name 名称
* @说明 这个是index方法
* @随便啥玩意 随便啥的说明
* 随便啥的说明第二行
* -#-%^&*;a'd--符号啥的也都可以
* @又一个名称
* 又一个名称的注释
* @author kel
* @version 1.0.0
*/
public function index(){
}
The MIT License (MIT). Please see License File for more information.