hassankerdash/laravel-api-respond
Composer 安装命令:
composer require hassankerdash/laravel-api-respond
包简介
Return readable API responses
README 文档
README
Overview
Laravel API Respond is a package designed to simplify the process of generating JSON responses in Laravel applications. It provides a convenient way to structure responses with consistent keys and formats, making API development more efficient.
Installation
You can install the package via Composer by running the following command:
composer require hassankerdash/laravel-api-respond
Usage
After installation, you can use the Respond service provided by the package to generate JSON responses in your Laravel controllers or services.
Basic Usage
// Generate a successful response return respond()->success(['key' => 'value'], 'Operation completed successfully'); // Generate an error response return respond()->error('Bad request'); respond()->error('Bad request')->throwResponse();
Methods
The Respond service provides the following methods for generating JSON responses:
success($data, $message = null, $code = 200, $status = true): Generate a successful response.error($message, $data = null, $code = 400, $status = false): Generate an error response.ok($data, $message = null, $code = 200, $status = true): Generate a response indicating success with status code 200.created($data, $message = null, $code = 201, $status = true): Generate a response indicating successful resource creation.accepted($data, $message = null, $code = 202, $status = true): Generate a response indicating that the request has been accepted for processing.noContent($message = null, $code = 204, $status = true): Generate a response with no content.badRequest($message, $data = null, $code = 400, $status = false): Generate a response indicating a bad request.notFound($message, $data = null, $code = 404, $status = false): Generate a response indicating that the requested resource was not found.methodNotAllowed($message, $data = null, $code = 405, $status = false): Generate a response indicating that the request method is not allowed.conflict($message, $data = null, $code = 409, $status = false): Generate a response indicating a conflict....(and more)
License
This package is open-source software licensed under the MIT license.
Author
Contributing
Contributions are welcome! Feel free to submit issues or pull requests on GitHub.
Support
For any questions or support, please contact Hassan Kerdash via GitHub Issues.
Changelog
See the CHANGELOG.md file for details on changes.
Versioning
This package follows Semantic Versioning.
Security Vulnerabilities
If you discover a security vulnerability within this package, please send an e-mail to Hassan Kerdash via kerdash@gmail.com. All security vulnerabilities will be promptly addressed.
Acknowledgements
Special thanks to all contributors and the Laravel community.
Keywords
Laravel, API, Respond, JSON, Response, Package
Tags
Laravel, API, Respond, JSON, Response, Package
Links
hassankerdash/laravel-api-respond 适用场景与选型建议
hassankerdash/laravel-api-respond 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 77 次下载、GitHub Stars 达 1, 最近一次更新时间为 2024 年 02 月 14 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 hassankerdash/laravel-api-respond 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 hassankerdash/laravel-api-respond 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 77
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 19
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-02-14