-
-
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
driver_class not working when using url connection parameter #3209
Comments
I found the cause: https://github.com/doctrine/dbal/blob/master/lib/Doctrine/DBAL/DriverManager.php#L403 But why? Is there no way to use a custom driver with |
@thomas-hiron I'm not sure why it's implemented this way. From what I understand, the In the meanwhile, could you try using a URI without the scheme? Like the following: $url = '//user:[email protected]/path?param=value';
var_dump(parse_url($url));
/*
array(5) {
'host' =>
string(11) "example.com"
'user' =>
string(4) "user"
'pass' =>
string(8) "password"
'path' =>
string(5) "/path"
'query' =>
string(11) "param=value"
}
*/ |
Yes it is working without the scheme! Should I create a PR to update the doc or wait for more comments to know what to do? |
I think this behavior is too confusing to be just documented. Unless there are some reasons I'm not aware of, the correct behavior should either of:
@Ocramius any idea why the current behavior is implemented this way? |
Any updates on this? |
After a long period of time, mysql server can go away. This packages (https://github.com/facile-it/doctrine-mysql-come-back) is a wrapper around the doctrine driver to reconnect if it went away. I've been looking for solutions to overwrite driver class (override mapping of pdo_mysql, add driver to $_driverMap, specify driver_class, ... but none of them worked/is possible). |
any update? |
For using custom DBAL Driver for Symfony 4/6 set the driver_class: App\DBAL\Driver in doctrine.yaml and very important, don't use url in doctrine.yaml and set:
|
Although this behavior is confusing, it's intentional: dbal/lib/Doctrine/DBAL/DriverManager.php Lines 401 to 403 in 9f3188a
Changing it would be a minor BC break. Closing for now. Please feel free to file a PR and change it in the next major release. |
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. |
Bug Report
Summary
While using complete url parameter to connect to database, I can't use a custom driver class.
I need to use all parameters (host, port, dbname, user, password).
Current behavior
driver_class
only works if all connection parameters are defined.How to reproduce
Clone
symfony/demo
project, use this workaround to create a custom driver.Add something like this to the driver:
Then run
bin/console doctrine:fixtures:load --purge-with-truncate
--> The text should not appear.Remove
DATABASE_URL
and use every parameters separately:Then the text should appear.
Expected behavior
A custom
driver_class
must be working when usingurl
parameter.I'll have a look if I can find something, but I lost a lot of time on this strange behavior.
The text was updated successfully, but these errors were encountered: