PHPackages                             hyperf-libs/helpers - 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. hyperf-libs/helpers

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

hyperf-libs/helpers
===================

基于hyperf日常开发工具包

2.3(2y ago)0398MITPHPPHP &gt;=8.1

Since Jan 13Pushed 2y ago1 watchersCompare

[ Source](https://github.com/hyperf-lib/helpers)[ Packagist](https://packagist.org/packages/hyperf-libs/helpers)[ RSS](/packages/hyperf-libs-helpers/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (10)Versions (7)Used By (0)

介绍
==

[](#介绍)

基于hyperf3.1框架，封装日常使用辅助类；主要包含日志(TraceId)调用、Redis调用、Redis分布式锁和常用函数等。

安装方式
====

[](#安装方式)

```
composer require hyperf-lib/helpers

```

发布配置文件
======

[](#发布配置文件)

```
php bin/hyperf.php vendor:publish hyperf-lib/helpers

```

常用函数
====

[](#常用函数)

获取容器实例

```
di(\Redis::class);  // Redis实例
di(\GuzzleHttp\ClientInterface::class);  // GuzzleHttp实例
di(\Helpers\Elasticsearch\Client::class);  // Elasticsearch实例

```

分转元，元转分

```
fen2yuan(100);
yuan2fen(1.00);

```

分布式锁

```
runWithLock($callback, $lockName, $lockSec, $waitSec);

```

API返回格式

```
apiSucc($data);
apiErr($code, $message);

```

分布式ID获取

```
getPkId();

```

异常堆栈信息格式化

```
formatThrowable($throwable);

```

Redis调用示例

```
Helpers\Redis::set('demo', 'demo');

```

日志调用示例

```
Helpers\Log::info(__FUNCTION__, []);
# 统一日志格式，可以将app/Listener/DbQueryExecutedListener.php:58
$this->logger->info(sprintf('[%s] %s', $event->time, $sql));
#替换为
Helpers\Log::info(sprintf('[%s] %s', $event->time, $sql));

```

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity62

Established project with proven stability

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

Recently: every ~192 days

Total

6

Last Release

796d ago

Major Versions

1.1 → 2.02024-03-11

PHP version history (2 changes)1.0PHP &gt;=7.3

2.0PHP &gt;=8.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/922971da07426372e3cf8f4d07ad078381a4165af6bdcaa9e1927bafe7abc5a2?d=identicon)[longfeiRen](/maintainers/longfeiRen)

---

Tags

phphyperf

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/hyperf-libs-helpers/health.svg)

```
[![Health](https://phpackages.com/badges/hyperf-libs-helpers/health.svg)](https://phpackages.com/packages/hyperf-libs-helpers)
```

###  Alternatives

[xmo/mine-core

mineadmin core package

1684.2k1](/packages/xmo-mine-core)

PHPackages © 2026

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