PHPackages                             itskr/skr-laravel - 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. itskr/skr-laravel

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

itskr/skr-laravel
=================

make your laravel skr

v1.0.0(6y ago)4431MITPHPPHP &gt;=7.0.0

Since Aug 22Pushed 6y agoCompare

[ Source](https://github.com/IT-SKR/skr-laravel)[ Packagist](https://packagist.org/packages/itskr/skr-laravel)[ RSS](/packages/itskr-skr-laravel/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependencies (2)Versions (2)Used By (0)

关于 about skr-laravel
====================

[](#关于-about-skr-laravel)

程序的唯一响应出口，帮助用户统一项目的响应格式，包括
response返回格式
throw Exception的格式
validate验证的返回格式

例如 example
----------

[](#例如-example)

在config中配置错误码

```
[
    'ILLEGAL_MOBILE'=>["800007","手机格式不正确",200],
]

```

以下三种方式返回相同格式数据给端上

```
return Skr::response('ILLEGAL_MOBILE');

```

```
throw Skr::exception('ILLEGAL_MOBILE');

```

```
Skr::check($request->all(),['mobile'=>['required','ILLEGAL_MOBILE']]);

```

端上收到的格式如下

```
{
    "code":"800007",
    "msg":"手机格式不正确",
    "data":null
}

```

配置项目 config
-----------

[](#配置项目-config)

step 1、下载composer包

```
composer require itskr/skr-laravel

```

step 2、config/app.php文件中的providers数组里面添加

```
Itskr\SkrLaravel\SkrServiceProvider::class

```

step 3、发布配置资源到config中，执行

```
php artisan vendor:publish --provider="Itskr\SkrLaravel\SkrServiceProvider"

```

step 4、屏蔽掉日志打印并拦截默认错误的输出，app/Exceptions/Handle.php文件中修改

```
    //屏蔽错误日志的打印
    protected $dontReport = [
        \Itskr\SkrLaravel\SkrException::class
    ];

    //将系统异常统一转化成系统繁忙
    public function render($request, Exception $exception)
    {
        //系统其他错误直接返回BUSY....可修改
        if (!$exception instanceof \Itskr\SkrLaravel\SkrException){
            return \Itskr\SkrLaravel\Skr::response('BUSY');
        }

        return parent::render($request,$exception);
    }

```

更多使用技巧 more
-----------

[](#更多使用技巧-more)

1、支持通过header自动识别响应格式，默认响应code、msg、data,参考config/skr/response.php

```
return [
    'default'=>[
        'source_headers'=>null,
        'err_prefix'=>'skr.errors.default',//指向错误码配置文件
        'response_format'=>['code','msg','data']//skr 默认返回格式
    ],
    'others'=>[
        'source_headers'=>[
            'skr-source-others'=>'skr_others' //当herder中存在键skr-source-others的值为skr_others 时则走此条规则
        ],
        'err_prefix'=>'skr.errors.default',
        'response_format'=>['errCode','errMsg','data']//skr 其他返回格式
    ]
];

```

2、用@符号开头，可以直接给端上返回错误信息，错误码取默认DEFAULT

```
throw Skr::exception('@自定义的错误');

```

3、用@符号开头，可以指定错误码

```
throw Skr::exception('@自定义的错误','1001');

```

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

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

2455d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/019e95706041058d4425d2dbd38d131338b5a0eb69a13ab18876008c8b4ddf60?d=identicon)[IT-SKR](/maintainers/IT-SKR)

---

Top Contributors

[![IT-SKR](https://avatars.githubusercontent.com/u/8287821?v=4)](https://github.com/IT-SKR "IT-SKR (17 commits)")

### Embed Badge

![Health badge](/badges/itskr-skr-laravel/health.svg)

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

###  Alternatives

[wireui/wireui

TallStack components

1.8k1.3M16](/packages/wireui-wireui)[livewire/volt

An elegantly crafted functional API for Laravel Livewire.

4195.3M84](/packages/livewire-volt)[ramonrietdijk/livewire-tables

Dynamic tables for models with Laravel Livewire

21147.4k](/packages/ramonrietdijk-livewire-tables)

PHPackages © 2026

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