PHPackages                             weiwait/laravel-helper - 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. weiwait/laravel-helper

ActiveLibrary

weiwait/laravel-helper
======================

laravel开发辅助

2.1.1(1y ago)1142MITPHPPHP ^8.1

Since May 8Pushed 1y ago1 watchersCompare

[ Source](https://github.com/weiwait/laravel-helper)[ Packagist](https://packagist.org/packages/weiwait/laravel-helper)[ RSS](/packages/weiwait-laravel-helper/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (10)Dependencies (1)Versions (15)Used By (0)

laravel-helper
==============

[](#laravel-helper)

### 助手函数

[](#助手函数)

- authUser(): App\\User | App\\Models\\User | null

    - 以ide友好方式获取认证后的用户（使用laravel自带的用户表）
- message(string $message, int $code = 1, int $status = 200, $jsonOption = JSON\_UNESCAPED\_UNICODE): JsonResponse

    - 纯消息响应

```
  public function index()
  {
      return message('operation success');
  }
```

- success(arrayable $data, int $code = 2, int $status = 200, $jsonOption = JSON\_UNESCAPED\_UNICODE): JsonResponse
    - 数据响应，数据或者实现了arrayable接口的对象，如collection

```
    public function index()
    {
        return success(User::all());
    }
```

- error(string $message, int $code = 0, int $status = 400, $jsonOption = JSON\_UNESCAPED\_UNICODE): JsonResponse
    - 错误消息响应

```
    public function index()
    {
        return error('something went wrong');
    }
```

### 助手类

[](#助手类)

- Tools::alterEnv(array $env)
    - 增加或者修改.env文本（将.env文件设为www用户php运行用户）若开启缓存将执行artisan config:cache命令
- Tools::imagesUrl(array $images)
    - 在api资源中使用可以将json多图或者关联多图调用Storage::url补全路径

### 异常处理

[](#异常处理)

- 捕获全局异常修改为统一响应格式, 全局http状态码皆为200

```
    [
        'message': 'error message',
        'code': 'exception->code()',
        'status': 'exception->getStatusCode() | 500'
    ]
```

- 单独处理表单验证

```
    [
        'message': '第一个验证不通过的错误信息',
        'errors': 'exception->errors() 所有的验证错误信息'
        'code': 'exception->code()',
        'status': '422'
    ]
```

- 用户认证处理，status 401
- Model Not Found处理， status 404

### 资源文件

[](#资源文件)

- 表单验证汉化包

```
 php artisan vendor:publish
```

- 选择 weiwait/laravel-helper

###  Health Score

35

—

LowBetter than 79% of packages

Maintenance34

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity72

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

Recently: every ~285 days

Total

14

Last Release

635d ago

Major Versions

1.2.2 → 2.0.02023-05-09

PHP version history (3 changes)1.0.0PHP ^7.3

1.1.3PHP ^7.3 | ^8.0

2.0.0PHP ^8.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/74e0a539fde4f31941cf773ea8504fa105f6c48dd8d3665c3f5ea13304c82292?d=identicon)[weiwait](/maintainers/weiwait)

---

Top Contributors

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

### Embed Badge

![Health badge](/badges/weiwait-laravel-helper/health.svg)

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

###  Alternatives

[anourvalar/eloquent-serialize

Laravel Query Builder (Eloquent) serialization

11320.2M21](/packages/anourvalar-eloquent-serialize)[namu/wirechat

A Laravel Livewire messaging app for teams with private chats and group conversations.

54324.5k](/packages/namu-wirechat)[statamic-rad-pack/runway

Eloquently manage your database models in Statamic.

135192.6k5](/packages/statamic-rad-pack-runway)

PHPackages © 2026

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