-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Allow to use a database DSN instead of all the database variables #414
Conversation
What happens if there is no password or no port in the DSN? |
I'm not necessarily against this, but wanted to point out two things:
"other locator/credentials stored in the config" is the key part which is exactly what Bedrock is doing.
I'm on the fence about this but open to opinions. Is this something you'd consider trying to contribute to WP core? It should definitely be supported by default but contributing to WP isn't something I'd wish on anyone 😂 |
They also doesn't support your structure, doesn't support composer, and dotenv. Your edition is "the right way" of doing Wordpress (yes Wordpress, we're not in 2004 anymore). So adding support is one step closer your goal. Also, it doesn't removes the actual way of doing :-), it just remove a little pain for cloud/paas users of bedrock Also: Nope, I don't want to contribute to Wordpress, they are decades away of good practices when it comes to web development. I imagine PR like this would be left over like the |
Also, I fixed a case where the code couldn't support a passwordless database connexion. Good catch @Kocal. |
The algorithm takes care of the following DSN variations:
I think this PR is now ready if you don't have more comments to add. |
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.
This also introduces a few new variables into the global scope. It's not a big deal, but I bring it up in case we want to discuss cleaning them up.
@QWp6t do you find this version better ? |
What is missing in order to merge and tag a new release of bedrock ? :D |
My question about the required env vars is still valid I think. If you just use |
@swalkinshaw I've updated the code to allow only |
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.
Looks good overall.
@austinpray good with you?
I'll give this a go tomorrow and merge. |
Great news thanks :-), if possible tag a new release right away so we can all benefit from my 2 last PR 🤓 |
Is there something missing I can add that prevents this PR to get merged ? :) |
Sweet, works here! |
@swalkinshaw @retlehs Let's get #412 in and then tag a new release? 1.12.0? |
Thank you, @austinpray thanks for providing reactive feedback on my work |
Hello,
As mentionned on the .README,
So I was surprised, during my 120+ Wordpress migration plan to add the same snippet over and over again to allow to use a DSN instead of all the random legacy Wordpress variables (
DB_NAME
,DB_USER
...).The 12Factor app is clearly in favor of using DSN: https://12factor.net/backing-services.
Also, when using a recent cloud provider, or PaaS provider, the often expose the database through a DSN (since they follow 12Factor App methodology too).
For those reading the PR and who don't know what a DSN is, it's a string containing the connection information. Ex:
So instead of breaking everything and force people to use DSN instead of legacy variables, this PR adds the support of DSN without breaking existing applications.
Basically, it you set a
DATABASE_URL
variable, then the code takes care of parsing the URL to set the correct variables.I've been running tests on local (where
DATABASE_URL
was not set) and on production (whereDATABASE_URL
was set) with no issues.I've updated the example and the documentation too.
Tell me what you think about it.
The algorithm takes care of the following DSN variations: