tattran22/response
最新稳定版本:2.0.4
Composer 安装命令:
composer require tattran22/response
包简介
Easy API Response Transformation for Laravel
README 文档
README
This Laravel package simplifies handling API responses using the Fractal library. It lets you easily:
- Transform data: Convert raw data into structured responses.
- Include relationships: Add related data to your responses without separate requests.
- Handle pagination: Automatically add pagination links and metadata.
Installation
Just run this command in your terminal:
composer require tattran22/response
Usage
- Prepare your data: Use Eloquent models, arrays, or any suitable format.
- Create a transformer: Define how to transform your data using a
ResponseTransformerclass. - Transform your data: Call
transformDatawith your data and transformer.use TatTran\Response\Transformers\ResponseTransformer; $transformer = new ResponseTransformer($manager); $response = $transformer->transformData($data, $transformerInstance);
- (Optional) Include relationships: Add
includeparameters to your API requests (e.g.,?include=relationship).$transformer->setIncludes(['include1', 'include2']);
Features
- Easy transformation: Define transformations in clear, readable code.
- Includes parsing: Automatically handle
includequery parameters. - Pagination support: Add pagination links and metadata seamlessly.
- Set includes programmatically: Control included relationships in code.
Open Source & Credits
This package is free to use under the MIT license and developed by Tat Tran.
统计信息
- 总下载量: 7
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Unknown
- 更新时间: 2024-02-21