2017 © Pedro Peláez
 

library apitest

Simple API TEST tool for Laravel REST

image

deathkel/apitest

Simple API TEST tool for Laravel REST

  • Tuesday, July 17, 2018
  • by deathkel
  • Repository
  • 1 Watchers
  • 13 Stars
  • 79 Installations
  • CSS
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 6 Versions
  • 11 % Grown

The README.md

APITEST

轻量级laravel REST接口测试工具

用于查看和测试后端REST接口, (*1)

Latest Version on Packagist Software License Total Downloads, (*2)

版本要求

laravel >= 5.1,php > 7, (*3)

安装

composer require deathkel/apitest

使用

请到注册服务提供者到Laravel服务提供者列表中。 方法1: 在config/app.php配置文件中,key为'providers'的数组中添加服务提供者, (*4)

        'providers'=>[
            //...
            Deathkel\Apitest\ApiTestServiceProvider::class
        ]

运行 'php artisan vendor:publish'将视图文件和静态文件发布到你们的项目中,请确保文件夹resource/views/api和public/api文件夹为空。 否则请自行复制使用本项目frotend文件中的blade和静态文件, (*5)

Route配置示例

请配置在debug模式开启下的路由,不要再生产环境中使用, (*6)

    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]);
        }
    }

默认加载所有控制器,你可以使用setConfig()方法来手动设置要加载的控制器,

    private function config(){
        return [
            'App\Http\Controllers\IndexController',
            'App\Http\Controllers\HomeController',
        ];
    }

    .....
    $reflection=new ApiReflection();
    $reflection->setConfig($this->config());
    $api=$reflection->getApi();
    .....

界面示例

注释说明

@apiTest : apiTest功能标识

  • 添加了该参数才能使用该工具的其他功能。否则注释只能以文本格式展示(可用于兼容老的注释)

@param {参数格式} {参数} {简单说明} : 查询参数

  • 参数格式:自定义参数的格式名称。如(int|string|可选)等等
  • 参数名称:查询参数的名称。如name,title等等
  • 简单说明:随意写点吧 > 注意用一个空格分割

@{任意名称} : 任意注释

  • author version ...

注意名称和说明之间用一个空格分割, (*7)

写法示例

/**
 * @apiTest
 * @param nullable|int name 名称
 * @说明 这个是index方法
 * @随便啥玩意 随便啥的说明
 * 随便啥的说明第二行
 * -#-%^&*;a'd--符号啥的也都可以
 * @又一个名称
 * 又一个名称的注释
 * @author kel
 * @version 1.0.0
 */
public function index(){

}

License

The MIT License (MIT). Please see License File for more information., (*8)

The Versions

17/07 2018

dev-master

9999999-dev https://github.com/deatkel/apitest

Simple API TEST tool for Laravel REST

  Sources   Download

MIT

The Requires

  • php >=7.0

 

The Development Requires

by Avatar KEL

12/07 2018

0.1.2

0.1.2.0 https://github.com/deatkel/apitest

Simple API TEST tool for Laravel REST

  Sources   Download

MIT

The Requires

  • php >=7.0

 

The Development Requires

by Avatar KEL

30/10 2017

dev-dev

dev-dev https://github.com/deatkel/apitest

Simple API TEST tool for Laravel REST

  Sources   Download

MIT

The Requires

  • php >=7.0

 

The Development Requires

by Avatar KEL

22/09 2017

0.1.1

0.1.1.0 https://github.com/deatkel/apitest

Simple API TEST tool for Laravel REST

  Sources   Download

MIT

The Requires

 

by Avatar KEL

01/09 2017

0.1.0

0.1.0.0 https://github.com/deatkel/apitest

Simple API TEST tool for Laravel REST

  Sources   Download

MIT

The Requires

 

by Avatar KEL

31/08 2016

0.0.1

0.0.1.0 https://github.com/deatkel/apitest

Simple API TEST tool for Laravel REST

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

by Avatar KEL