Skip to content

[DoctrineBundle] resolve parameters inside DATABASE_URL #204

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

Merged
1 commit merged into from
Nov 10, 2017
Merged

[DoctrineBundle] resolve parameters inside DATABASE_URL #204

1 commit merged into from
Nov 10, 2017

Conversation

nicolas-grekas
Copy link
Member

Q A
License MIT

Not ready to merge yet, because this relies on DI >=3.4.
If we want to allow this with 3.3, we might patch DoctrineBundle.
But before doing so, what about just moving to require >=3.4 for all Symfony components?
Any other idea?

Copy link
Contributor

@symfony-bot symfony-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request passes validation.

@aik099
Copy link

aik099 commented Oct 4, 2017

Actually I don't like DATABASE_URL as single DSN for database, because it only works with Doctrine and doesn't work with PdoSessionHandler, that expects DSN in different format and username/password as separate variables.

I wish we could revert back to use 4 env variables as in Symfony 3.3 (that's what I did for now in my project to avoid specifying DB credentials in 2 different formats).

@javiereguiluz
Copy link
Member

Could we fix PdoSessionHandler to support this new DSN format instead?

@aik099
Copy link

aik099 commented Oct 4, 2017

The DSN format isn't new, but isn't standard PDO DSN either. Not sure how to do this without breaking BC, but I see 2 options:

  1. either duplicate Doctrine DSN parser (for all DB types) in PdoSessionHandler

pros: PdoSessionHandler works with Doctrine bundle not installed
cons: code duplication

  1. or make PdoSessionHandler literally share connection that Doctrine creates

pros: you will see DB queries made by PdoSessionHandler in Web Profiler
cons: PdoSessionHandler would depend on DoctrineBundle

P.S.
If Doctrine has DSN parser as standalone package, then we can use it. Haven't checked.

@nicolas-grekas
Copy link
Member Author

nicolas-grekas commented Oct 4, 2017

@aik099 please open an issue if you want to discuss this, that's another topic.

@aik099
Copy link

aik099 commented Oct 4, 2017

Created #206.

@aik099
Copy link

aik099 commented Oct 18, 2017

Will the resolve: prefix work for Symfony 3.3 as well?

@fabpot
Copy link
Member

fabpot commented Oct 30, 2017

We need to decide what to do here. I think we should probably just merge as is and let 3.3 users behind.

@weaverryan
Copy link
Member

I don't see any other option. We could temporarily (until 3.4 is released) add a comment above this line:

For Symfony 3.3, remove the "resolve:" part: parameters cannot live inside environment vars

@fabpot
Copy link
Member

fabpot commented Oct 31, 2017

Problem is that cache:clear will fail immediately as the syntax is not valid in 3.3.

@fabpot
Copy link
Member

fabpot commented Nov 8, 2017

So?

@@ -1,6 +1,6 @@
doctrine:
dbal:
url: '%env(DATABASE_URL)%'
url: '%env(resolve:DATABASE_URL)%'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a comment for people using 3.3? Something like # If you are using Symfony 3.3, remove the resolve: prefix

Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request passes validation.

@ghost ghost merged commit c11e8c5 into symfony:master Nov 10, 2017
ghost pushed a commit that referenced this pull request Nov 10, 2017
@nicolas-grekas nicolas-grekas deleted the resolve-db-url branch November 30, 2017 17:41
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants