giatechindo/hypervel-response-formatter
Composer 安装命令:
composer require giatechindo/hypervel-response-formatter
包简介
Standardized response formatter for Hypervel framework
README 文档
README
Standardized API response formatter for Hypervel framework with PCOV coverage support.
Features
-
Consistent JSON response structure
-
Success and error response helpers
-
PSR-7 compatible responses
-
Built-in test coverage support
-
IDE-friendly method chaining
-
Testing di Project
-
https://github.com/Giatechindo/hypervel-testing
Installation
composer require giatechindo/hypervel-response-formatter
📺 Playlist
Berikut adalah playlist video pembelajaran yang dapat Anda ikuti:
🔗 Klik di sini untuk membuka playlist di YouTube
Configuration
The package auto-registers itself. For manual configuration:
// config/autoload/dependencies.php return [ 'dependencies' => [ 'invokables' => [ \Giatechindo\HypervelResponseFormatter\ResponseFormatter::class => \Giatechindo\HypervelResponseFormatter\ResponseFormatter::class, ], ], ];
Usage
Basic Responses
<?php declare(strict_types=1); namespace App\Http\Controllers; use Giatechindo\HypervelResponseFormatter\ResponseFormatter; use Hyperf\HttpServer\Contract\ResponseInterface; class UserController { public function index(ResponseInterface $response) { $users = [ ['id' => 1, 'name' => 'John'], ['id' => 2, 'name' => 'Jane'], ]; return (new ResponseFormatter($response))->success($users, 'Users retrieved successfully', 200); } public function show(ResponseInterface $response) { return (new ResponseFormatter($response))->error('User not found', ['id' => 'Invalid ID'], 404); } }
Success Response
return response()->success( data: ['id' => 1, 'name' => 'John'], message: 'User retrieved', statusCode: 200 );
Response:
{
"success": true,
"message": "User retrieved",
"data": {
"id": 1,
"name": "John"
}
}
Error Response
return response()->error( message: 'Validation failed', errors: ['email' => 'Invalid format'], statusCode: 422 );
Response:
{
"success": false,
"message": "Validation failed",
"errors": {
"email": "Invalid format"
}
}
Without Data/Errors
return response()->success(message: 'Operation completed'); return response()->error(message: 'Not found', statusCode: 404);
Response Structure
Success
{
"success": true,
"message": "string",
"data": {} // optional
}
Error
{
"success": false,
"message": "string",
"errors": {} // optional
}
Testing
# Install PCOV for coverage (Ubuntu) sudo apt-get install php8.3-pcov # Run tests with coverage vendor/bin/phpunit --coverage-html coverage # View coverage report xdg-open coverage/index.html
Development Setup
Clone repository:
git clone git@github.com:Giatechindo/hypervel-response-formatter.git
Install dependencies:
composer install
Run tests:
composer test
Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
License
MIT
Giatechindo Community - GitHub | Packagist
Download Options
- Copy-paste the above content into a new
README.mdfile - Or download directly using:
curl -o README.md https://gist.githubusercontent.com/raw/... # Replace with actual URL if uploaded
This documentation includes:
- All working features from our implementation
- Installation instructions
- Usage examples
- Response structures
- Testing setup with PCOV
- Development guidelines
- Contribution info
giatechindo/hypervel-response-formatter 适用场景与选型建议
giatechindo/hypervel-response-formatter 是一款 基于 HTML 开发的 Composer 扩展包,目前已累计 17 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 05 月 11 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 giatechindo/hypervel-response-formatter 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 giatechindo/hypervel-response-formatter 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 17
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 13
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-05-11