承接 hamid-re3a/response-transformer 相关项目开发

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

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

hamid-re3a/response-transformer

Composer 安装命令:

composer require hamid-re3a/response-transformer

包简介

Simple transfomer to return Json responses.

README 文档

README

The main purpose of this package is to return the response in the desired way as the frontend development team requested.

Setup:

This is a private package. So, the installation process is completely different. For this purpose, we recorded 2 videos which you can watch to learn how to install this package.

  1. Installation
  2. After installation, register the package service provider in app.php file like other packages.
    • \ResponseTransformerServiceProvider::class
  3. Register the package façade alias in app.php file:
    • 'RTransformer' => ResponseTransformer\Facades\API::class
  4. Finally you can publish the config file:
    • php artisan vendor:publish --tag=transformer-response

Usage:

You can using this package as façade as well as a helper function.

01. Helper Function:

public function index()
{
    $user = User::first();
    return api()->response(200, 'The very first user in the database', $user);
}

02. Facade:

use RTransformer;
public function index()
{
    $user = User::first();
    return RTransformer->response(200, 'The very first user in the database', $user);
}

Response

{
      "status": 200,
      "message": "The very first user in the database",
      "data": [
           {"name": "Hamid Noruzi"}
       ]
}

统计信息

  • 总下载量: 2.41k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 4
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-12-11