承接 tattran22/response 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

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

  1. Prepare your data: Use Eloquent models, arrays, or any suitable format.
  2. Create a transformer: Define how to transform your data using a ResponseTransformer class.
  3. Transform your data: Call transformData with your data and transformer.
    use TatTran\Response\Transformers\ResponseTransformer;
    
    $transformer = new ResponseTransformer($manager);
    $response = $transformer->transformData($data, $transformerInstance);
  4. (Optional) Include relationships: Add include parameters 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 include query 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

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: Unknown
  • 更新时间: 2024-02-21