-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Use DSN-like strings to define credentials #572
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
Conversation
I need someone to explain me why I needed to make this change --> f3d8340 to make this work. Thanks! |
Well, your second commit is because what you defined was not a URL-based DSN for SQLite. It was only a path. |
@stof that was the problem! I'm an idiot 😊 However, if I change that, I now see this:
|
hmm, this message is not clear |
@javiereguiluz, dumper throws an exception because you don't use the |
@javiereguiluz, see @dmaicher's comment #557 (comment) |
@voronkovich thanks for your comments. That was indeed the error and the proposed fix solved the issue. Thanks! |
phpunit.xml.dist
Outdated
@@ -10,6 +10,7 @@ | |||
<php> | |||
<ini name="error_reporting" value="-1" /> | |||
<server name="KERNEL_DIR" value="app/" /> | |||
<env name="DATABASE_URL" value="sqlite://%kernel.project_dir%/var/data/blog_test.sqlite"/> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think you can use a parameter here, in an actual env var
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually you are right but it still works 😄
Really weird what happens now when dumping the connection within a test to see the config:
-_params: array:9 [
"url" => "sqlite://%kernel.project_dir%/var/data/blog_test.sqlite"
"host" => "%kernel.project_dir%"
"port" => null
"user" => "root"
"password" => null
"driver" => "pdo_sqlite"
"driverOptions" => []
"defaultTableOptions" => []
"path" => "var/data/blog_test.sqlite"
]
This seems to be more correct:
<env name="DATABASE_URL" value="sqlite:///var/data/blog_test.sqlite" />
==>
-_params: array:9 [
"url" => "sqlite:///var/data/blog_test.sqlite"
"host" => "localhost"
"port" => null
"user" => "root"
"password" => null
"driver" => "pdo_sqlite"
"driverOptions" => []
"defaultTableOptions" => []
"path" => "var/data/blog_test.sqlite"
]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@javiereguiluz FYI see above
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@javiereguiluz, compiled container doesn't interpolate parameters in environment variables. See https://github.com/symfony/symfony/blob/v3.3.0/src/Symfony/Component/DependencyInjection/Container.php#L442
Thank you all for your help making this mergeable! |
This is the new best practice for modern Symfony apps. See https://github.com/symfony/recipes/blob/master/symfony/swiftmailer-bundle/2.5/etc/packages/swiftmailer.yaml