artyuum/symfony-jsend-response
最新稳定版本:1.2.0
Composer 安装命令:
composer require artyuum/symfony-jsend-response
包简介
JSendResponse component for HttpFoundation based applications (Symfony, Silex, Laravel, Drupal, etc.). It follows the JSend specification, allowing you to give consistent JSON responses to your users.
README 文档
README
JSendResponse component for HttpFoundation based applications (Symfony, Silex, Laravel, Drupal, etc.). It follows the JSend specification, allowing you to give consistent JSON responses to your users.
Note: This repository is a maintened fork of Junker/JSendResponse. See the releases page for modification history.
Requirements
- PHP ^7.4 || ^8.0
- Symfony ^5.0 || ^6.0 || ^7.0
Installation
The best way to install JSendResponse is to use a Composer:
composer require artyuum/symfony-jsend-response
Examples
use Junker\JSendResponse\JSendResponse; use Junker\JSendResponse\JSendSuccessResponse; use Junker\JSendResponse\JSendFailResponse; use Junker\JSendResponse\JSendErrorResponse; class AppController { ... $data = ['id' => 50, 'name' => 'Waldemar']; $message = 'Error, total error!'; $code = 5; return new JSendResponse(JSendResponse::STATUS_SUCCESS, $data); // or return new JSendResponse(JSendResponse::STATUS_FAIL, $data); // or return new JSendResponse(JSendResponse::STATUS_ERROR, NULL, $message); // or return new JSendResponse(JSendResponse::STATUS_ERROR, $data, $message, $code); // or return new JSendSuccessResponse($data); // or return new JSendFailResponse($data); // or return new JSendErrorResponse($message); // or return new JSendErrorResponse($message, $code, $data); }
Contributing
If you'd like to contribute, please fork the repository and make changes as you'd like. Be sure to follow the same coding style & naming used in this library to produce a consistent code.
统计信息
- 总下载量: 44.91k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-04-18