hamid-re3a / response-transformer
Simple transfomer to return Json responses.
Installs: 2 189
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 0
Open Issues: 0
Requires
- php: ^7.3|^8.0
This package is auto-updated.
Last update: 2025-08-29 03:00:32 UTC
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.php
file like other packages.-
\ResponseTransformerServiceProvider::class
-
- Register the package façade alias in
app.php
file:-
'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"}
]
}