PHPackages                             bugsheng/laravel-api-response - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. bugsheng/laravel-api-response

ActiveLibrary[API Development](/categories/api)

bugsheng/laravel-api-response
=============================

Laravel Lumen response api

1.0.9(2y ago)117MITPHPPHP ^7.0|^8.0

Since Mar 26Pushed 2y ago1 watchersCompare

[ Source](https://github.com/bugsheng/laravel-api-response)[ Packagist](https://packagist.org/packages/bugsheng/laravel-api-response)[ RSS](/packages/bugsheng-laravel-api-response/feed)WikiDiscussions main Synced 3w ago

READMEChangelog (3)Dependencies (2)Versions (12)Used By (0)

laravel-api-response
====================

[](#laravel-api-response)

> 简单封装通用前后端分离使用接口传输数据时候的数据格式定义

### 安装

[](#安装)

```
composer require bugsheng/laravel-api-response
```

### 数据内容格式

[](#数据内容格式)

```
{
    "code": 0,
    "message": "请求成功",
    "data": {
      "user": {}
    }
}

```

### 用法

[](#用法)

1. 方式一

    Http 请求状态 都是200 成功

```
// 成功携带数据
\ApiRes::success(['info' => ['name' => 'Jone', 'age' => 20]], '数据获取成功');

// 失败携带数据
// 携带自定义错误码
\ApiRes::fail('数据获取失败', ['notice_type' => 1, 'notice_message' => '示例方式'], 10000);
// 不携带错误码 使用默认400错误码
\ApiRes::fail('数据获取失败', ['notice_type' => 1, 'notice_message' => '示例方式']);

// 成功无数据
\ApiRes::message('提交成功');

// 失败无数据
// 携带自定义错误码
\ApiRes::errorMessage('提交失败', 10001);
// 使用默认400错误码
\ApiRes::errorMessage('提交失败');
```

2. 方式二

```
\Illuminate\Support\Facades\Response::success();
\Illuminate\Support\Facades\Response::fail();

参数与方式一相同
```

### 框架要求

[](#框架要求)

Laravel &gt;= 5.5

###  Health Score

27

—

LowBetter than 47% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~118 days

Recently: every ~197 days

Total

10

Last Release

856d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/16681022?v=4)[第五焱陽](/maintainers/shenglin-php)[@shenglin-php](https://github.com/shenglin-php)

---

Top Contributors

[![shenglin-php](https://avatars.githubusercontent.com/u/16681022?v=4)](https://github.com/shenglin-php "shenglin-php (1 commits)")

### Embed Badge

![Health badge](/badges/bugsheng-laravel-api-response/health.svg)

```
[![Health](https://phpackages.com/badges/bugsheng-laravel-api-response/health.svg)](https://phpackages.com/packages/bugsheng-laravel-api-response)
```

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3355.3M346](/packages/psalm-plugin-laravel)[defstudio/telegraph

A laravel facade to interact with Telegram Bots

815320.5k3](/packages/defstudio-telegraph)[simplestats-io/laravel-client

Analytics for Laravel. Track visitors, registrations, and payments. Discover which channels actually drive revenue, not just traffic. Server-side, GDPR compliant, ad-blocker proof.

5019.3k](/packages/simplestats-io-laravel-client)[jasara/php-amzn-selling-partner-api

A fluent interface for Amazon's Selling Partner API in PHP

1348.7k1](/packages/jasara-php-amzn-selling-partner-api)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
