PHPackages                             themismin/laravel-api - 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. themismin/laravel-api

ActiveLibrary[API Development](/categories/api)

themismin/laravel-api
=====================

Laravel api interface extension package

v1.2.0(2y ago)09311MITPHPPHP &gt;=7.1.0CI failing

Since Aug 30Pushed 2y ago1 watchersCompare

[ Source](https://github.com/themismin/laravel-api)[ Packagist](https://packagist.org/packages/themismin/laravel-api)[ RSS](/packages/themismin-laravel-api/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (1)Versions (12)Used By (1)

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

[](#laravel-api)

Laravel api 接口扩展包

### 安装

[](#安装)

```
composer require themismin/laravel-api

php artisan vendor:publish --provider="ThemisMin\LaravelApi\LaravelApiServiceProvider"
```

### 配置

[](#配置)

> 在状态资源文件 resource/response-code/\*.php 配置响应code

> 1.0.\* 版本

```
/** response code common */
return [
    /** 自定义码 => HTTP 响应状态码, 预留, 响应消息 */

    /** 未认证 */
    '401' => ['status_code' => 401, 'status' => 'error', 'message' => 'Unauthenticated.',],
    /** 参数错误 */
    '422' => ['status_code' => 422, 'status' => 'error', 'message' => 'The given data was invalid.',],

    /** 成功  */
    '200' => ['status_code' => 200, 'status' => 'success', 'message' => '成功',],

    /** http_code 200, 接口 code 200401 */
    '200401' => ['status_code' => 200, 'status' => 'success', 'message' => '成功',],
];
```

> 1.1.\* 版本

```
/** response code common */
return [
    /** 自定义码 => HTTP 响应状态码, 预留, 响应消息 */

    /** 未认证 */
    '401' => ['http_code' => 401, 'status' => 'error', 'message' => 'Unauthenticated.',],
    /** 参数错误 */
    '422' => ['http_code' => 422, 'status' => 'error', 'message' => 'The given data was invalid.',],

    /** 成功  */
    '200' => ['http_code' => 200, 'status' => 'success', 'message' => '成功',],

    /** 当 http_code 未设置时，默认为 200 */
    '200' => ['status' => 'success', 'message' => '成功',],

    /** http_code 200, 接口 code 200401 */
    '200401' => ['http_code' => 200, 'status' => 'success', 'message' => '成功',],
    /** 或 */
    '200401' => ['status' => 'success', 'message' => '成功',],

];
```

> 异常处理器

./bootstrap/app.php

```
// $app->singleton(
//     Illuminate\Contracts\Debug\ExceptionHandler::class,
//     App\Exceptions\Handler::class
// );
$app->singleton(
    Illuminate\Contracts\Debug\ExceptionHandler::class,
    ThemisMin\LaravelApi\Exceptions\Handler::class
);
```

### 使用

[](#使用)

```
return response_json(['id' => "1"]);

> http_code:200 {"code":200,"status":"success","message":"success","data":{"id":"1"}}
```

```
return response_json(['id' => '1'], 401);

> http_code:401 {"code":401,"status":"error","message":"Unauthenticated.","data":{"id":"1"}}
```

```
return response_json(['id' => '1'], 200401);

> http_code:200 {"code":200401,"status":"error","message":"Unauthenticated.","data":{"id":"1"}}
```

###  Health Score

32

—

LowBetter than 71% of packages

Maintenance31

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity63

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 ~205 days

Recently: every ~422 days

Total

11

Last Release

753d ago

PHP version history (4 changes)1.0.0PHP ^7.2

1.0.2PHP ^5.6

1.0.3PHP &gt;=5.6.4

v1.2.0PHP &gt;=7.1.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/8c800de9c17265b0c85ee3c8e2be6f196b2dfb0c0a5692f5d7ca9e8ee6064df2?d=identicon)[themismin](/maintainers/themismin)

---

Top Contributors

[![themismin](https://avatars.githubusercontent.com/u/5857863?v=4)](https://github.com/themismin "themismin (13 commits)")

---

Tags

responsejsonapilaravel

### Embed Badge

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

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

###  Alternatives

[obiefy/api-response

Simple Laravel package to return Json responses.

17324.6k](/packages/obiefy-api-response)[nilportugues/laravel5-json-api-dingo

Laravel5 JSONAPI and Dingo together to build APIs fast

311.5k](/packages/nilportugues-laravel5-json-api-dingo)[nilportugues/laravel5-haljson

Laravel 5 HAL+JSON API Transformer Package

151.0k](/packages/nilportugues-laravel5-haljson)[nicklaw5/larapi

A simple Laravel 5 class for handling json api responses.

111.5k](/packages/nicklaw5-larapi)

PHPackages © 2026

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