orm
orm copied to clipboard
[QUESTION] How to have a master/slave (rw/r) setup with Laravel Doctrine
I am using version 1.4 and I wonder how can I configure it in a way it can leverage different configurations (host, username, password) to perform reads and writes as I do want to use it in a setup where I have one master and possibly many slaves to spread the reads.
You need to set proper config on doctrine.connections.[connection]
. Doesnt look like we have documentation sadly.
Take a look a the tests: https://github.com/laravel-doctrine/orm/blob/1.5/tests/EntityManagerFactoryTest.php#L893
The configuration for the connection class is resolved by: https://github.com/laravel-doctrine/orm/blob/1.5/src/Configuration/Connections/MasterSlaveConnection.php#L39 The $settings
argument is the value you provide in doctrine.connections.[connection]
.
The value returned from this resolve
method is sent to Doctrine\DBAL\Connections\MasterSlaveConnection
.