orm icon indicating copy to clipboard operation
orm copied to clipboard

[QUESTION] How to have a master/slave (rw/r) setup with Laravel Doctrine

Open bicatu opened this issue 5 years ago • 1 comments

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.

bicatu avatar Oct 30 '19 12:10 bicatu

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.

eigan avatar Nov 21 '19 06:11 eigan