reptily/api-check
最新稳定版本:0.0.1
Composer 安装命令:
composer require reptily/api-check
包简介
Quick check of external API
README 文档
README
Install
composer require reptily/api-check
what problem does this helper solve?
Laravel façade doesn't handle big data well
Large Array Example
$users = []; $user = [ 'id' => 1, 'name' => 'Bob', 'is_active' => true, 'books' => [] ]; $book = [ 'id' => 1, 'name' => 'test book', ]; for ($i=0; $i < 100; $i++) { $user['books'][] = $book; } for ($i=0; $i < 500; $i++) { $users[] = $user; }
benchmark facade Validator
Validator::make($users, [ '*.id' => ['required', 'integer'], '*.name' => ['required', 'string'], '*.is_active' => ['required', 'boolean'], '*.books' => ['required', 'array'], '*.books.*.id' => ['required', 'integer'], '*.books.*.name' => ['required', 'string'], ]);
End time: 84.0274 sec.
benchmark ApiCheck
ApiCheck::structure([ ApiCheck::TYPE_ARRAYS => [ 'id' => ApiCheck::TYPE_INTEGER, 'name' => ApiCheck::TYPE_STRING, 'is_active' => ApiCheck::TYPE_BOOLEAN, 'books' => [ ApiCheck::TYPE_ARRAYS => [ 'id' => ApiCheck::TYPE_INTEGER, 'name' => ApiCheck::TYPE_STRING, ] ] ] ], $users);
End time: 0.1269 sec.
Who USED ?!
Example base response
{
"id": 1,
"name": "Bob"
}
ApiCheck
$result = ApiCheck::checker($response, [ 'id' => ApiCheck::TYPE_INTEGER, 'name' => ApiCheck::TYPE_STRING, ]);
Example for array
["bob", "sara", "john"]
ApiCheck
$result = ApiCheck::checker($response, [ApiCheck::TYPE_ARRAYS => ApiCheck::TYPE_STRING]);
Example for array
{
"data": [
{
"name": ["car", "foot", "ball"]
},
{
"name": ["room", "tree"]
}
]
}
ApiCheck
$result = ApiCheck::checker($response, [ 'data' => [ ApiCheck::TYPE_ARRAYS => [ 'names' => [ ApiCheck::TYPE_ARRAYS => ApiCheck::TYPE_STRING, ], ], ], ]);
统计信息
- 总下载量: 3
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: GPL-3.0-or-later
- 更新时间: 2023-11-10