2017 © Pedro Peláez
 

symfony-bundle doctrine-multi-schema-bundle

Enables multiple schemas for Doctrine + Symfony

image

shoofly/doctrine-multi-schema-bundle

Enables multiple schemas for Doctrine + Symfony

  • Friday, December 8, 2017
  • by smcjones
  • Repository
  • 1 Watchers
  • 0 Stars
  • 852 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 8 Versions
  • 13 % Grown

The README.md

Enables Multiple Schemas for MySQL on Doctrine, (*1)

I created this bundle to fulfill a need for one of my projects. It is not thoroughly tested for all use cases, and will be regularly updated., (*2)

If you find this useful but spot a bug, I welcome PRs., (*3)

The Premise

Doctrine treats MySQL databases the same as PostgreSQL databases. The truth is that MySQL databases are closer in nature to a PostgreSQL schema, and the term DATABASE can be used interchangeably with SCHEMA in MySQL, even in syntax:, (*4)

CREATE {DATABASE | SCHEMA} [IF NOT EXISTS] db_name ...

This makes it very difficult to handle MySQL layouts that use more than one schema - often a reality in inherited code., (*5)

If your personal use case is transferring an existing project with multiple schemas into a Symfony project, and you'd like to use Doctrine, then this bundle seeks to make that possible., (*6)

Installation

In your Symfony project, install with, (*7)

composer require shoofly/doctrine-multi-schema-bundle

Add to your Symfony AppKernel.php:, (*8)

$bundles = [
    new Shoofly\DoctrineMultiSchemaBundle\ShooflyDoctrineMultiSchemaBundle(),
];

Configuraiton

IMPORTANT: Remove your driver and platform, and replace it with these two parameters., (*9)

doctrine:
    dbal:
        driver_class: 'Shoofly\DoctrineMultiSchemaBundle\DBAL\MySQL\Driver'
        platform_service: "shoofly_doctrine_multi_schema.platform57"
        # for MySQL < 5.7, choose this:
        # platform_service: "shoofly_doctrine_multi_schema.platform"

Next, list the schemas you want to include in your ORM:, (*10)

shoofly_doctrine_multi_schema:
    schemas:
        - foo
        - baz
        - bar

That should be the only configuration you need. If you run into any issues, please let me know., (*11)

Hope this helps someone else. If not, it's already helped me :), (*12)

The Versions