承接 yared/api-response 相关项目开发

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

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

yared/api-response

最新稳定版本:v1.0.0

Composer 安装命令:

composer require yared/api-response

包简介

Advanced API response formatter for Laravel

README 文档

README

Advanced API response formatter for Laravel. Provides consistent, professional JSON responses for your API.

Installation

composer require yared/api-response

Or for local development, add to your Laravel project's composer.json:

{
    "repositories": [
        {
            "type": "path",
            "url": "../laravel-api-response"
        }
    ]
}

Then:

composer require yared/api-response

Publish Config

php artisan vendor:publish --tag=api-response-config

Usage

Success Response

use Yared\ApiResponse\Facades\ApiResponse;

return ApiResponse::success($user, "User fetched successfully");

Error Response

return ApiResponse::error("User not found", 404);

Pagination

return ApiResponse::paginate(User::paginate(10));

Validation Errors

return ApiResponse::error("Validation failed", 422, $validator->errors());

Example Output

{
    "success": true,
    "message": "Users retrieved",
    "data": [...],
    "meta": {
        "request_id": "f24e4f21-...",
        "timestamp": "2026-03-05T22:50:00+00:00"
    }
}

Configuration

Edit config/api-response.php to customize:

  • success_key - Key for success flag
  • message_key - Key for message
  • data_key - Key for data payload
  • meta_key - Key for meta information
  • request_id - Include unique request ID
  • include_timestamp - Include response timestamp

Middleware

Add FormatApiResponse middleware to API routes for automatic response formatting. Register in app/Http/Kernel.php:

protected $middlewareAliases = [
    // ...
    'api.format' => \Yared\ApiResponse\Middleware\FormatApiResponse::class,
];

License

MIT

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-03-06

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固