Download the PHP package lzpeng/hyperf-cycle without Composer
On this page you can find all versions of the php package lzpeng/hyperf-cycle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Please rate this library. Is it a good library?
Informations about the package hyperf-cycle
hyperf-cycle
Cycle ORM 在 Hyperf 中的连接池支持。
该库基于 hyperf/pool 为 Cycle ORM 提供协程安全的数据库连接复用能力,同时尽量保持与原生 Cycle ORM 一致的配置和使用方式。
特性
- 基于
hyperf/pool的数据库连接池 - 按协程隔离
Database与ORM实例 - 自动回收连接,减少长驻进程中的连接泄露风险
- 保持与 Cycle ORM 接近的配置结构
- 支持 MySQL、PostgreSQL、SQLite、SQL Server
安装
发布配置
安装后可发布默认配置:
发布后会生成数据库配置文件,你可以在其中维护连接信息和连接池参数。
配置示例
连接池参数
| 参数 | 说明 |
|---|---|
min_connections |
最小连接数 |
max_connections |
最大连接数 |
connect_timeout |
建立连接超时时间 |
wait_timeout |
从连接池获取连接的等待时间 |
heartbeat |
心跳检测间隔 |
max_idle_time |
连接最大空闲时间 |
使用方式
推荐:从容器获取
该库通过 ConfigProvider 注册了 DatabaseManager 与 ORMFactory,通常直接从容器取用即可:
手动创建
说明
- 本库主要解决 Hyperf 场景下的 Cycle ORM 连接池与协程隔离问题。
- 实体映射、Schema、Repository 等能力仍遵循标准 Cycle ORM 用法。
- 数据库连接会在协程生命周期结束时自动释放。
注意事项
由于hyperf是一个长驻进程框架,连接对象不要作为对象类的属性进行持久化,否则会导致连接泄露问题或事务问题。建议在需要使用数据库连接的地方通过容器获取 DatabaseManager 或 ORMFactory 来获取连接实例,确保连接能够正确回收。
错误使用示例:
正确例子:
All versions of hyperf-cycle with dependencies
PHP Build Version
Package Version
Requires
php Version
>=8.1
cycle/orm Version ^2.8
hyperf/pool Version ^3.1
cycle/entity-behavior Version ^1.3
cycle/orm Version ^2.8
hyperf/pool Version ^3.1
cycle/entity-behavior Version ^1.3
The package lzpeng/hyperf-cycle contains the following files
Loading the files please wait ...