Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/smcjones/doctrine-multi-schema-bundle
Enables multiple schemas for Doctrine + Symfony + MySQL
https://github.com/smcjones/doctrine-multi-schema-bundle
bundle dbal doctrine mysql symfony symfony-bundle
Last synced: about 2 months ago
JSON representation
Enables multiple schemas for Doctrine + Symfony + MySQL
- Host: GitHub
- URL: https://github.com/smcjones/doctrine-multi-schema-bundle
- Owner: smcjones
- Created: 2017-04-03T22:05:30.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2017-12-08T05:06:53.000Z (about 7 years ago)
- Last Synced: 2024-11-15T20:18:29.441Z (3 months ago)
- Topics: bundle, dbal, doctrine, mysql, symfony, symfony-bundle
- Language: PHP
- Homepage:
- Size: 18.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Enables Multiple Schemas for MySQL on Doctrine
*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.*
*If you find this useful but spot a bug, I welcome PRs.*
## 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](https://dev.mysql.com/doc/refman/5.7/en/create-database.html):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.
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.
## Installation
In your Symfony project, install with
composer require shoofly/doctrine-multi-schema-bundle
Add to your Symfony AppKernel.php:$bundles = [
new Shoofly\DoctrineMultiSchemaBundle\ShooflyDoctrineMultiSchemaBundle(),
];
## Configuraiton**IMPORTANT:** Remove your driver and platform, and replace it with these two parameters.
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:
shoofly_doctrine_multi_schema:
schemas:
- foo
- baz
- barThat should be the only configuration you need. If you run into any issues, please let me know.
Hope this helps someone else. If not, it's already helped me :)