Database slaves when using Lumen with Doctrine

Posted 5 months ago by FerdinandFrank

I'm currently using Lumen with the Doctrine2 drop-in implementation for Laravel 5+ as an ORM within a project and we need to be able to declare multiple read databases (one main db with two slaves). According to the official Laravel docs, there can be multiple read databases defined like this in database.php:

'mysql' => [
    'read' => [
        'host' => ['192.168.1.1', '192.168.1.2', '192.168.1.3'],
    ],
    ...
]

But this configuration only works when using Eloquent or the native Laravel query builder. When using the Doctrine drop-in, the read database has to be configured like this, otherwise it can not resolve the host:

'mysql' => [
    'read' => [
        ['host' => '192.168.1.1'],
    ],
    ...
]

Is it possible to define multiple read databases in Lumen when using the Doctrine drop-in and is it even supported by Doctrine? It should be possible when using Doctrine natively but I couldn't find anything in the docs of the Doctrine2 drop-in implementation for Laravel 5+. Does anyone have some experience with it?

Please sign in or create an account to participate in this conversation.