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.
- Installation
- Video 01: https://drive.google.com/file/d/1Bic6tk3b5cjQp3rQM3DS_Nj94O2qb77V/view
- Video 02: https://drive.google.com/file/d/1yOJwaOvs9MKukk-Hh1NA_DG2ZITM8zBr/view
- Auth URL: https://packagist.com/profile/auth
- Private Package Setup Guide: https://packagist.com/docs/setup#basic-setup
- After installation, register the package service provider in
app.phpfile like other packages.-
\ResponseTransformerServiceProvider::class
-
- Register the package façade alias in
app.phpfile:-
'RTransformer' => ResponseTransformer\Facades\API::class
-
- 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
- 点击次数: 3
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-12-11