Skip to content

Get started

Install

These pages document the Core 3-compatible 2.x bundle line.

Use a 2.x release with Core 3:

composer require small/swoole-entity-manager-bundle:^2.0

If no 2.x release has been published yet and you are explicitly testing the development line, use dev-main instead of mixing the released 1.1.x bundle with Core 3.

The v2 package currently requires:

  • PHP >=8.3 <8.5;
  • small/swoole-entity-manager-core 3.0.*;
  • Symfony Config, Console, DependencyInjection and HttpKernel ^7.4 || ^8.0.

Configuration

Create config/packages/small_swoole_entity_manager.yaml:

small_swoole_entity_manager:
  default_connection: default

  connections:
    default:
      type: mysql
      host: database.my-app.net
      port: 3306
      encoding: utf8mb4
      database: app
      user: app
      password: secret
      max_connections: 50

    users:
      type: postgres
      host: postgres.my-app.net
      port: 5432
      encoding: UTF8
      database: sso_users
      user: postgres
      password: secret123
      max_connections: 25

    memory:
      type: swoole-db

  database_layers:
    app: "@projectRoot/databaseLayers"
    users: "@UserBundle/Resources/databaseLayers"

  layer_parameters:
    application_environment: prod
    tenant: main

Supported connection types are:

  • mysql;
  • postgres;
  • swoole-db.

For SQL connections, host, database, user, password and encoding are required. An empty password is allowed when the database configuration intentionally uses one.

port is optional and must be between 1 and 65535. max_connections is optional and must be at least 1. The bundle normalizes these public Symfony-style options to the Core connection configuration (port as a string and maxConnections internally).

A swoole-db connection accepts only its type option.

When connections are configured, default_connection must name one of them.

Database-layer paths

database_layers maps a selector to a layer directory.

A path beginning with @projectRoot is resolved from KernelInterface::getProjectDir(). Other @Bundle/... resource paths are resolved through the Symfony kernel.

Only values listed under layer_parameters are passed to Core database layers. The bundle does not expose Symfony's full container parameter bag to migration code.

Next chapter: Instantiate managers