PHPackages                             superwen/laravel-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. [Utility &amp; Helpers](/categories/utility)
4. /
5. superwen/laravel-response

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

superwen/laravel-response
=========================

laravel-response

v1.0.0(4y ago)05MITPHPPHP ^7.2.5 || ^8.0

Since Apr 12Pushed 4y ago1 watchersCompare

[ Source](https://github.com/superwen/laravel-response)[ Packagist](https://packagist.org/packages/superwen/laravel-response)[ Docs](https://github.com/superwen/laravel-response.git)[ RSS](/packages/superwen-laravel-response/feed)WikiDiscussions main Synced 1mo ago

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

superwen/laravel-response
=========================

[](#superwenlaravel-response)

基于sunnanbei/laravel-response更新的response类

这个包的目的是？
--------

[](#这个包的目的是)

在项目开发时，由于获取数据方式不同(ORM、DB、自定义...)，会出现返回格式不统一的情况。
如果使用laravel自带的API资源(Resource)可以完美解决这个问题。
但，并不是每一个资源都需要去创建Resource的。
所以这个package的目的就是为了确保常见场景下，返回格式统一，保证唯一性。

如何使用
----

[](#如何使用)

```
composer require superwen/laravel-response
```

```
```

```
//请求成功，输出数据，返回200
return Response::success($data);
```

```
{
    "error_code": 0,
    "message": "请求成功.",
    "data": {},
    "meta": {},
    "error": "",
    "debug": []
}
```

```
{
    "error_code": 0,
    "message": "请求成功.",
    "data": [],
    "meta": {},
    "error": "",
    "debug": []
}
```

```
{
    "error_code": 0,
    "message": "请求成功.",
    "data": {
        "id": 1,
        "name": "北京"
    },
    "meta": {},
    "error": "",
    "debug": []
}
```

```
{
    "error_code": 0,
    "message": "请求成功.",
    "data": [
        {
            "id": 1,
            "name": "北京"
        },
        {
            "id": 2,
            "name": "上海"
        }
    ],
    "meta": {
        "pagination": {
            "total": 100,
            "current_page": 1,
            "last_page": 50,
            "per_page": 2
        }
    },
    "error": "",
    "debug": []
}
```

```
//请求失败，系统异常，返回500
return Response::error();
```

```
//请求失败，返回200
return Response::fail();
```

```
//请求成功，返回201
return Response::created();
```

```
//请求成功，返回204
return Response::noContent();
```

```
//请求成功，返回403
return Response::forbidden();
```

```
//请求成功，返回404
return Response::notFound();
```

```
//接管异常
···
use Superwen\Response\Exceptions\JsonResponse;

class Handler extends ExceptionHandler
{
    use JsonResponse;
···
```

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

 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

Unknown

Total

1

Last Release

1490d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/1d8811d1e86f2171bfe23b1f77ad61939cfd74a47ea35e5a2449dfd5a93fcbe4?d=identicon)[superwen](/maintainers/superwen)

---

Top Contributors

[![huannet](https://avatars.githubusercontent.com/u/38235158?v=4)](https://github.com/huannet "huannet (1 commits)")

### Embed Badge

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

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

###  Alternatives

[illuminate/pipeline

The Illuminate Pipeline package.

9446.6M212](/packages/illuminate-pipeline)[illuminate/pagination

The Illuminate Pagination package.

10532.5M862](/packages/illuminate-pagination)[spatie/laravel-livewire-wizard

Build wizards using Livewire

4061.0M4](/packages/spatie-laravel-livewire-wizard)[illuminate/broadcasting

The Illuminate Broadcasting package.

7126.5M178](/packages/illuminate-broadcasting)[illuminate/redis

The Illuminate Redis package.

8314.0M314](/packages/illuminate-redis)[bensampo/laravel-embed

Painless responsive embeds for videos, slideshows and more.

142146.8k](/packages/bensampo-laravel-embed)

PHPackages © 2026

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