-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Standalone DSN parser #5814
Comments
@stof, I think your input can help on this issue. |
this is exactly the opposite of the needs of Symfony though. The whole point is to avoid caching the parsed credentials so that you don't need to clear the cache when credentials change (on most PaaS, clearing cache requires a new deployment, while credentials are injected as env variable in the container without rebuilding the image when they change). However, having it as a separate class that parses the URL and merges that with an array of options (with the explicit options winning over the URL, at least when non-null) might solve it |
I wrote "can be cached". Of course, you shouldn't do it if the DSN can change at any time without cache invalidation. Caching those values would be the responsibility of the application that configures the DBAL connection. The idea is that the application contains bootstrapping logic like this: $parameters = $dsnParser->parse($dsn);
// Post-process the parameters as you see fit!
$connection = DriverManager::getConnection($parameters); In case of Symfony, that logic would reside in DoctrineBundle. |
I've started working on this feature in #5843. |
Fixed via #5843 |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Feature Request
Summary
In #5697, we have deprecated driver aliases for database URLs. One use-case of those aliases was to be able to parse a credentials URL like
mysql://my_user:[email protected]
that are usually provided by a PaaS services. With the changes on 4.0, those database URLs would become specific to Doctrine because we would have to usemysqli://
orpdo-mysql://
as scheme.My idea would be to deprecate the
url
option completely and replace it with a standalone DSN parser that translates a given DSN into an array of options that can be passed toDriverManager
. This parser can be configured with a scheme-to-driver mapping (e.g.['mysql' => 'pdo_mysql']
).I see several advantages of this approach:
DriverManager
's internal logic gets a little bit simpler.The text was updated successfully, but these errors were encountered: