定制 lzpeng/hyperf-cycle 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

lzpeng/hyperf-cycle

最新稳定版本:1.0.7

Composer 安装命令:

composer require lzpeng/hyperf-cycle

包简介

Cycle ORM support for hyperf

README 文档

README

Cycle ORM support for hyperf

使用Hyperf/Pool增加连接池功能

用法与CycleORM基本相同:

use Lzpeng\HyperfCycle\DatabaseManager;
use Lzpeng\HyperfCycle\Config\DatabaseConfig;
use Lzpeng\HyperfCycle\Config\MySQLDriverConfig;
use Cycle\Database\Config\MySQL\TcpConnectionConfig;

$databaseManager = new DatabaseManager(
    new DatabaseConfig([
        'default' => 'default',
        'databases' => [
            'default' => ['connection' => 'mysql']
        ],
        'connections' => [
            'mysql' => new MySQLDriverConfig(
                connection: new TcpConnectionConfig(
                    database: 'spiral',
                    host: '127.0.0.1',
                    port: 3306,
                    user:'spiral',
                    password: '',
                ),
                queryCache: true,
                // 增加了连接池配置
                poolOptions: [ 
                    'min_connections' => 1,
                    'max_connections' => 20,
                    'connect_timeout' => 10.0,
                    'wait_timeout' => 3.0,
                    'heartbeat' => -1,
                    'max_idle_time' => 60.0,
                ]
            ),
        ]
    ])
);

$container = /** 获取容器 **/
$schemaConfig = /** schema配置 **/;

$schema = new Schema($schemaConfig);
$commandGenerator = new EventDrivenCommandGenerator($schema, $container);

$ormFactory = new ORMFactory($databaseManager, $schema, $commandGenerator);

//  获取ORM实例
$orm = $ormFactory->orm();

// 获取EntityManager实例
$em = $ormFactory->entityManager();

统计信息

  • 总下载量: 480
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-06-22