Support database URLs inside read and write connections #58522
Unanswered
LachlanArthur
asked this question in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
The
'url'item in database configs is not supported inside the read and write connection overrides.The read and write connection documentation does not make this clear, it implies that all keys are supported:
For example, this does not work, even though the docs imply it should:
This is caused by:
urlvalue is expanded byIlluminate\Database\DatabaseManagerinto its constituent parts (host, port, etc), usingIlluminate\Support\ConfigurationUrlParserIlluminate\Database\Connectors\ConnectionFactorywhich is responsible for determining the read and write connections (if configured) and picking a random one to use.Illuminate\Database\Connectors\ConnectionFactorybails when it fails to find mandatory keys such ashost.At no point does the
urlvalue within the read/write arrays get read.The reason to support this is it would simplify the env vars quite a lot for sites with multiple databases each with read replicas.
Since this is such a fundamental part of Laravel, I'm hesitant to attempt to make a PR to add this feature - at least not without input from the maintainers.
Beta Was this translation helpful? Give feedback.
All reactions