PHPackages                             ruesin/utils - 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. [Logging &amp; Monitoring](/categories/logging)
4. /
5. ruesin/utils

ActiveLibrary[Logging &amp; Monitoring](/categories/logging)

ruesin/utils
============

Some commonly used helper classes

v1.0.2(7y ago)01252Apache-2.0PHP

Since Jan 14Pushed 6y ago1 watchersCompare

[ Source](https://github.com/ruesin/utils)[ Packagist](https://packagist.org/packages/ruesin/utils)[ Docs](https://github.com/ruesin)[ RSS](/packages/ruesin-utils/feed)WikiDiscussions master Synced 5d ago

READMEChangelog (2)DependenciesVersions (4)Used By (2)

Utils
=====

[](#utils)

一些常用的辅助工具类。

Config
------

[](#config)

类似`Laravel`的配置类，可以通过"."分割的方式设置、获取配置信息。

- `loadPath($path)`：加载目录下的PHP文件，设置为以文件名为key的Config的配置项
- `loadFile($file_name)`：加载指定文件，设置文件名为key
- `set($key, $value)`：设置配置项`$key`的值为`$value`
- `get($key, $default = null)`：获取`$key`的配置值

假设目录`/tmp/config/`目录下有文件`mysql.php`：

```
return [
    'web' => [
        'host' => '127.0.0.1',
        'port' => '3306',
        'user' => 'root',
        'pass' => 'root',
        'database' => 'web_db'
    ],
    'server' => [
        'host' => '127.0.0.2',
        'port' => '3306',
        'user' => 'ruesin',
        'pass' => 'ruesin',
        'database' => 'server_db'
    ]
];
```

使用：

```
//加载 /tmp/config 目录下的所有 php 文件，文件名作为配置数组的key
Config::loadPath('/tmp/config/');
//加载 /tmp/config/mysql.php 文件
Config::loadFile('/tmp/config/mysql.php');
/*
Config::$config = [
    'mysql' => [
        'web' => [...],
        'server' => [....],
    ]
];
*/
//将 Config::$config['mysql']['web']['user'] 的值改为 ruesin
Config::set('mysql.web.user', 'ruesin');

//获取Config::$config['mysql']['server']的值
print_r(Config::get('mysql.server'));
/*
[
    'host' => '127.0.0.2',
    'port' => '3306',
    'user' => 'ruesin',
    'pass' => 'ruesin',
    'database' => 'server_db'
]
*/
```

Log
---

[](#log)

使用`file_put_contents`的简单文件日志类，默认文件写入`/tmp/`目录，可以通过初始化`init($config)`更改配置。

```
//初始化配置，log_path为日志存储目录，unique_id为日志文件唯一标识，默认为当前进程号。
Log::init(['log_path' => '/your-log-path/', 'unique_id' => '123']);

//向 /your-log-path/ruesin/default.log 文件追加写入 This is my message!
Log::msg('This is my message!', 'default', 'ruesin');

//向 /your-log-path/ruesin/info.log 文件追加写入 [2019-01-14 22:53:00] This is my info!
Log::info('This is my info!', 'info', 'ruesin');
```

###  Health Score

29

—

LowBetter than 59% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community11

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

Total

3

Last Release

2645d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/ec297750aef9224002f4917df5768fa3013e0f2604fe2bd72cbcde81a9959747?d=identicon)[ruesin](/maintainers/ruesin)

---

Top Contributors

[![ruesin](https://avatars.githubusercontent.com/u/8240739?v=4)](https://github.com/ruesin "ruesin (20 commits)")

---

Tags

logconfigutils

### Embed Badge

![Health badge](/badges/ruesin-utils/health.svg)

```
[![Health](https://phpackages.com/badges/ruesin-utils/health.svg)](https://phpackages.com/packages/ruesin-utils)
```

###  Alternatives

[monolog/monolog

Sends your logs to files, sockets, inboxes, databases and various web services

21.4k964.9M7.0k](/packages/monolog-monolog)[psr/log

Common interface for logging libraries

10.4k1.2B9.2k](/packages/psr-log)[symfony/monolog-bundle

Symfony MonologBundle

2.9k249.1M1.6k](/packages/symfony-monolog-bundle)[spatie/laravel-activitylog

A very simple activity logger to monitor the users of your website or application

5.8k45.4M309](/packages/spatie-laravel-activitylog)[sentry/sentry

PHP SDK for Sentry (http://sentry.io)

1.9k227.1M273](/packages/sentry-sentry)[sentry/sentry-laravel

Laravel SDK for Sentry (https://sentry.io)

1.3k114.3M154](/packages/sentry-sentry-laravel)

PHPackages © 2026

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