small/swoole-entity-manager-bundle

Small Swoole Entity Manager Bundle 是一个针对 Small Swoole 实体管理器的 Symfony 扩展包,它是一个为 Swoole 定制的 ORM

0.1.1 2024-08-02 21:59 UTC

This package is auto-updated.

Last update: 2024-09-02 22:16:45 UTC


README

Small Swoole Entity Manager Bundle

Small Swoole Entity Manager 是一个为 Swoole 和 OpenSwoole 设计的 ORM。

此包是其与 Symfony 的桥梁。

  

安装

composer require small/swoole-entity-manager-bundle

要配置数据库连接,创建一个 "config/packages/small_swoole_entity_manager.yaml" 文件

small_swoole_entity_manager:
  default_connection: test
  connections:
    test:
      type: mysql
      host: localhost
      database: test_db
      user: root
      encoding: utf8
      password: dev

可能的类型值:"mysql" 或 "postgres"

获取管理器

现在,您可以通过 Symfony 容器获取您的管理器

$this->container
    ->get(\Small\SwooleEntityManagerBundle\Contract\EntityManagerFactoryInterface::class)
    ->get(\Small\SwooleEntityManagerBundle\Test\Fixture\EntityManager\UserManager::class)
;

有关如何使用管理器的信息,请参阅 Small Swoole Entity Manager 文档。

获取连接

您还可以检索 Small Swoole Entity Manager 连接以执行原生语句

$connection = $this->container
    ->get(\Small\SwooleEntityManagerBundle\Contract\ConnectionFactoryInterface::class)
    ->get('test')
;

有关如何使用连接的信息,请参阅 Small Swoole Entity Manager 文档。