承接 uxmansarwar/response 相关项目开发

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

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

uxmansarwar/response

Composer 安装命令:

composer require uxmansarwar/response

包简介

Elegant and lightweight PHP Composer Package for standardized API responses with error, ttl, query and result handling. Package developed by UxmanSarwar a Senior PHP Developer since 2013

README 文档

README

Packagist PHP Version License GitHub Stars

🔍 Overview

uxmansarwar/response is a powerful yet lightweight PHP package that makes it easy to manage structured API responses. Built with modern PHP practices, it follows a clean singleton pattern and supports result grouping, TTL, debug queries, and more. Ideal for Laravel, Symfony, WordPress, CodeIgniter, or raw PHP projects.

Developed and maintained by Uxman Sarwar, a senior PHP developer since 2013.

✅ Features

  • Singleton-based fluent API
  • Add results, errors, queries, TTL, and input metadata
  • Auto-collects $_GET, $_POST, and raw JSON input
  • Customizable result/error key groups with key() and index()
  • Get structured responses as JSON or array
  • Great for APIs, microservices, and AJAX handlers

⚙️ Installation

Via Composer

composer require uxmansarwar/response

🚀 Quick Start

Initialize

use UxmanSarwar\Response;

Response::init();

Add Result

Response::result(['id' => 1, 'name' => 'Alice']);

Add Error

Response::error('Invalid request type');

Grouped Result with Key/Index

Response::key('user')->index('info')->result(['email' => 'user@example.com']);

Set Time-To-Live (TTL)

Response::ttl(60);

Attach Debug Query

Response::query('SELECT * FROM users WHERE id = 1');

Include Input Data

Response::input(true);

Output as JSON

echo Response::json();

Output as Array

print_r(Response::array());

💡 Example Use Case: API Endpoint

Response::init();

if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
    Response::error("Only POST requests are allowed");
} else {
    $data = Response::$_INPUT;
    if (empty($data['username'])) {
        Response::error("Username is required");
    } else {
        Response::result("User registered successfully");
    }
}

echo Response::json();

🧪 Testing

composer install
vendor/bin/phpstan analyse src --level=max
vendor/bin/pest

🌐 Use Cases

  • Laravel: Replace default response()->json() with a fluent helper
  • WordPress: Handle AJAX with structured output
  • Symfony: Wrap controller responses with grouped structure
  • REST APIs: Make consistent error/result formatting
  • Microservices: Inject debug info and TTL for downstream caching

👨‍💻 About the Author

This package is created by Uxman Sarwar, a full-stack PHP Laravel developer.

If you found this package useful, consider ⭐ starring the repo and sharing it with other developers.

🔗 SEO & GitHub Keywords

PHP API response library, structured API output PHP, response formatter, Laravel response helper, singleton response PHP, uxmansarwar response composer, REST API output PHP, error handler class PHP, api response json PHP, PHP response class Laravel

📥 Composer Install Reminder

composer require uxmansarwar/response

Happy coding! 🚀

uxmansarwar/response 适用场景与选型建议

uxmansarwar/response 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 166 次下载、GitHub Stars 达 2, 最近一次更新时间为 2025 年 02 月 22 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「php」 「json」 「api」 「error handling」 「response」 「data collector」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 uxmansarwar/response 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 uxmansarwar/response 我们能提供哪些服务?
定制开发 / 二次开发

基于 uxmansarwar/response 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-02-22