PHPackages                             felo-z/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. [Database &amp; ORM](/categories/database)
4. /
5. felo-z/laravel-helper

ActiveLibrary[Database &amp; ORM](/categories/database)

felo-z/laravel-helper
=====================

Laravel helper

v4.0.0(1w ago)09MITPHPPHP ^8.4

Since Jan 25Pushed 2mo agoCompare

[ Source](https://github.com/Felo-Z/laravel-helper)[ Packagist](https://packagist.org/packages/felo-z/laravel-helper)[ Docs](https://github.com/Felo-Z/laravel-helper)[ GitHub Sponsors](https://github.com/Felo-Z)[ RSS](/packages/felo-z-laravel-helper/feed)WikiDiscussions main Synced today

READMEChangelog (4)Dependencies (28)Versions (6)Used By (0)

Laravel Helper
==============

[](#laravel-helper)

Laravel 辅助工具包，提供 SQL 日志、日志清理、缓存清理和常用调试函数。

要求
--

[](#要求)

- PHP &gt;= 8.4
- Laravel `^13.0`

安装
--

[](#安装)

```
composer require felo-z/laravel-helper -vvv
```

### 发布配置文件

[](#发布配置文件)

```
php artisan vendor:publish --provider="FeloZ\LaravelHelper\HelperServiceProvider"
```

功能
--

[](#功能)

### SQL 日志

[](#sql-日志)

SQL 日志模块会在包启动时自动监听 `DB::listen()`，无需额外调用。

支持能力：

- 全量 SQL 与慢查询分流
- HTTP / Console / Queue Job 来源识别
- 绑定值替换、请求方法过滤、连接过滤
- 按执行作用域分组输出

最小配置示例：

```
'sql_logger' => [
    'enabled' => env('FELO_HELPER_SQL_LOGGER_ENABLED', false),
]
```

详细配置、占位符、环境变量与生产建议见：[`docs/sql-logger.md`](docs/sql-logger.md)

### Artisan 命令

[](#artisan-命令)

#### 清理日志文件

[](#清理日志文件)

```
php artisan felo:clear-logs
```

根据配置清理指定目录下的日志文件，支持自定义扩展名和排除文件。

#### 清理缓存

[](#清理缓存)

```
php artisan felo:clear-cache
```

清理 Laravel 缓存和指定的 Redis 连接。

### 辅助函数

[](#辅助函数)

#### 日志清理 / 缓存清理

[](#日志清理--缓存清理)

```
clear_logs();   // 清理日志文件
clear_cache();  // 清理 Laravel 缓存和 Redis
```

#### 调试输出

[](#调试输出)

将变量 JSON 化写入 `storage/logs` 目录，方便排查问题：

```
pas($data);          // dump + 写入文件
das($data);          // dd + 写入文件
las($data);          // 仅写入文件（静默）
zas('filename', $data); // 写入指定文件名
```

文件名默认按时间生成，格式为 `.json`。

#### 工具函数

[](#工具函数)

```
now_tz_bj();         // 获取北京时区当前时间（Carbon 实例）
format_bytes(1024);  // "1 KB"
format_duration(65000); // "1 min 5 s"
```

配置说明
----

[](#配置说明)

发布配置文件后，可在 `config/felo-helper.php` 中进行配置：

```
return [
    'clear_logs' => [
        'directories' => env('FELO_HELPER_LOG_DIRECTORIES', [storage_path('logs')]),
        'extensions' => env('FELO_HELPER_LOG_EXTENSIONS', 'log,sql,json'),
        'exclude' => env('FELO_HELPER_LOG_EXCLUDE', 'laravel.log'),
    ],
    'clear_cache' => [
        'clear_laravel_cache' => env('FELO_HELPER_CLEAR_LARAVEL_CACHE', true),
        'redis_connections' => env('FELO_HELPER_REDIS_CONNECTIONS', 'default'),
    ],
    'sql_logger' => [
        'enabled' => env('FELO_HELPER_SQL_LOGGER_ENABLED', false),
        'directory' => env('FELO_HELPER_SQL_LOGGER_DIRECTORY', storage_path('logs/sql')),
        'replace_bindings' => env('FELO_HELPER_SQL_LOGGER_REPLACE_BINDINGS', true),
    ],
];
```

SQL 日志完整配置见：[`docs/sql-logger.md`](docs/sql-logger.md)

### 环境变量

[](#环境变量)

```
FELO_HELPER_LOG_DIRECTORIES=/path/to/logs1,/path/to/logs2
FELO_HELPER_LOG_EXTENSIONS=log,json,txt
FELO_HELPER_LOG_EXCLUDE=laravel.log,important.log
FELO_HELPER_CLEAR_LARAVEL_CACHE=true
FELO_HELPER_REDIS_CONNECTIONS=default,cache
FELO_HELPER_SQL_LOGGER_ENABLED=false
FELO_HELPER_SQL_LOGGER_DIRECTORY=/path/to/storage/logs/sql
FELO_HELPER_SQL_LOGGER_REPLACE_BINDINGS=true
```

更多 SQL 日志环境变量见：[`docs/sql-logger.md`](docs/sql-logger.md)

开发
--

[](#开发)

```
composer run fix-style
composer run phpstan
composer run test
```

License
-------

[](#license)

MIT

###  Health Score

41

—

FairBetter than 87% of packages

Maintenance92

Actively maintained with recent releases

Popularity4

Limited adoption so far

Community2

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

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

Total

5

Last Release

10d ago

Major Versions

v1.1.0 → v2.0.02026-04-28

v2.0.0 → v3.0.02026-04-28

v3.0.0 → v4.0.02026-06-24

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/6071340?v=4)[zhangfei](/maintainers/Felo-Z)[@Felo-Z](https://github.com/Felo-Z)

---

Tags

laravelhelpersqlartisanlogscache

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StyleLaravel Pint

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[anourvalar/eloquent-serialize

Laravel Query Builder (Eloquent) serialization

11223.5M33](/packages/anourvalar-eloquent-serialize)[statamic-rad-pack/runway

Eloquently manage your database models in Statamic.

135224.7k7](/packages/statamic-rad-pack-runway)[mostafaznv/laracache

LaraCache is a customizable cache trait to cache queries on model's events

27250.9k2](/packages/mostafaznv-laracache)[tyghaykal/laravel-seed-generator

Laravel Seed Generator

8252.0k1](/packages/tyghaykal-laravel-seed-generator)[mozex/laravel-scout-bulk-actions

Import, flush, and queue-import all your Laravel Scout searchable models at once. Auto-discovers models, runs in bulk, tracks progress.

1539.3k](/packages/mozex-laravel-scout-bulk-actions)[pragmarx/sqli

A Laravel Artisan SQL Interactive Interface

591.9k](/packages/pragmarx-sqli)

PHPackages © 2026

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