tzookb /
laravel api 响应助手
0.01
2015-06-23 21:59 UTC
Requires
- illuminate/contracts: 5.*
This package is auto-updated.
Last update: 2024-09-17 09:43:37 UTC
README
此包旨在简化 API 响应的返回,目前它只返回 JSON,但可以轻松支持 XML 或其他格式...
使用简单
return $apiResponder
->setData(['someData'=>1, 'someData2'=>2])
->setMeta(['page'=>1, 'extra'=>'for_info_stuff'])
->setRef(1) //defaults to 1, this is for the general api code, like 0 success, 1 data error, 2 auth error etc
->respond(); //and this returns the "Response" object currently JsonResponse