feat: add wp-bedrock project type, fixes #8179#8219
Conversation
|
Download the artifacts for this pull request:
See Testing a PR. |
c1ac843 to
84ddfef
Compare
rfay
left a comment
There was a problem hiding this comment.
This needs a quickstart test in docs/tests/wp-bedrock.bats.
I'm struggling a bit with user-facing naming. I'm thinking it should be something like wp-bedrock as the project type (user facing).
Would you mind adding a new type in ddevapp_test.go so this gets tested the same way as the other project types? This is more work and perhaps less value than the quickstart tests, and requires a content source (a repo with a default version of everything, see how the others work)
|
https://github.com/ddev/ddev/actions/runs/22970758591/job/66686551435#step:8:163
|
96cf8dd to
9387e9d
Compare
9387e9d to
ff417e1
Compare
rfay
left a comment
There was a problem hiding this comment.
Thanks for this, I think it's a great addition to WP support.
Minor comments. The biggest one is we could have a static .env probably if we switch to the env var for the URL. That makes maintenance simpler.
Claude also has a few comments, mostly trivial, following.
Claude comments.env management timing — confirmed OK
Issues found1. Alphabetical ordering in values.go (minor)
2. Auto-detection order concern (minor, likely OK in practice)
3. No WP_SITEURL set in .env (OK but worth noting) The old quickstart explicitly set SummaryThe PR is well-structured. The core logic in Should-fix:
Worth considering:
|
|
Should |
ff417e1 to
93a86c0
Compare
|
Verified via Claude Code review — built the PR binary and tested What I did:
Result: The PR wires this up in
These combine to resolve the destination as |
93a86c0 to
8a34cdb
Compare
8a34cdb to
9f1cd3b
Compare
e605024 to
90e19c1
Compare
rfay
left a comment
There was a problem hiding this comment.
I think this is doing everything I had hoped now.
- Added "prefer to run as a script"
- Use $DDEV_PRIMARY_URL in .env
- Put .env as static asset in embedded asset, check for #ddev-generated
46cd583 to
78ba236
Compare
|
I don't like that we take over the https://github.com/roots/bedrock/blob/master/.env.example It has more variables inside than we set, I will make it work in the same way as in Laravel. |
I actually like this, but we can't use it right now because of: Maybe I could find some better approach how to handle this later. |
|
It's OK to go back to the previous setup with generated .env instead of packaged .env |
Add first-class support for Roots Bedrock as a DDEV project type. - Add AppTypeBedrock constant and register in appTypeMatrix - Implement detection via config/application.php marker file - Implement bedrockPostStartAction to manage .env with DB credentials and WP_HOME - Set docroot to "web" via bedrockConfigOverrideAction - Add bedrock to wp global command ProjectTypes so ddev wp works - Add detection fixture and TestConfigOverrideAction coverage - Update Bedrock quickstart docs to use --project-type=bedrock Co-Authored-By: Claude Opus 4.6 <[email protected]>
Rename user-facing project type from "bedrock" to "wp-bedrock" per
reviewer feedback, and add standalone quickstart bats test.
- Rename AppTypeBedrock -> AppTypeWPBedrock ("wp-bedrock")
- Create docs/tests/wp-bedrock.bats (extracted from wordpress.bats)
- Update quickstart docs, testdata directory, and test references
Co-Authored-By: Claude Opus 4.6 <[email protected]>
…ames [skip buildkite] Align internal file and function names with the wp-bedrock project type: bedrock.go -> wp_bedrock.go, isBedrockApp -> isWPBedrockApp, etc. Co-Authored-By: Claude Opus 4.6 <[email protected]>
…kite] Co-Authored-By: Claude Opus 4.6 <[email protected]>
Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
…mple manipulation
Replace the postStartAction env-file manipulation approach with a
settingsCreator that writes a DDEV-managed static .env from an
embedded asset (wordpress/bedrock/bedrock.env). The file uses
WP_HOME="${DDEV_PRIMARY_URL}" so phpdotenv resolves the URL at
runtime from the container environment rather than baking it in at
generation time. The file carries the #ddev-generated signature so
users can take ownership by removing that line.
Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Use a cookie jar to POST credentials to wp-login.php and follow the redirect, then assert the wp-admin Dashboard is present in the response body, confirming a real authenticated login. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Bedrock is a WordPress variant with its own project type. Without this guard, DetectAppType would match an installed Bedrock project as plain wordpress (since "wordpress" sorts before "wp-bedrock"), silently skipping Bedrock-specific .env management and upload dirs. Mirrors the IsWSL2/IsWSL2MirroredMode pattern: the more specific detector takes precedence over the general one. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
- Revert buggy GetComposerCreateAllowedPaths change that inserted .env as a directory component in the .gitignore path; .env is already handled by skipDirs in composer-create-project.go - Add setWPBedrockSiteSettingsPaths so SiteDdevSettingsFile is set to the .env path, making it visible to GetComposerCreateAllowedPaths and other DDEV internals - Add hookDefaultComments: getWordpressHooks so ddev config suggests WordPress hooks for Bedrock projects - Change ddev launch target from /wp/wp-login.php to /wp/wp-admin/ in quickstart.md and bats test, consistent with the WordPress quickstart - Sync wp-bedrock.bats with quickstart: test that /wp/wp-admin/ redirects to wp-login.php when unauthenticated (mirrors wordpress.bats pattern) and verify ddev launch /wp/wp-admin/ URL Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
The instructions line "remove the #ddev-generated line above" contained the signature string itself, causing FgrepStringInFile to still find silently overwrite the file instead of treating it as user-managed. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
78ba236 to
217a401
Compare
We would need to maintain the whole file, so if Bedrock adds something new in there, then our code won't reuse I updated the logic, and now # Generate your keys here: https://roots.io/salts.html
AUTH_KEY='generateme'
SECURE_AUTH_KEY='generateme'
LOGGED_IN_KEY='generateme'
NONCE_KEY='generateme'
AUTH_SALT='generateme'
SECURE_AUTH_SALT='generateme'
LOGGED_IN_SALT='generateme'
NONCE_SALT='generateme' |
rfay
left a comment
There was a problem hiding this comment.
Thanks @jonesrussell and @stasadev for all the work on this. This is another step toward consistent application-level .env usage.
I manually tested, and did db+files export and import successfully.
The Issue
wordpresstype #8179Adds first-class support for Bedrock as a DDEV project type, so users can run
ddev config --project-type=wp-bedrockinstead of manually configuring WordPress with docroot and.envoverrides.How This PR Solves The Issue
AppTypeWPBedrockconstant (wp-bedrock) and registers it in theappTypeMatrixafterwordpressalphabeticallywpBedrockConfigOverrideActionto auto-set docroot toweb.envfrom an embedded static asset (wordpress/bedrock/bedrock.env) viasettingsCreator, usingWP_HOME="${DDEV_PRIMARY_URL}"so phpdotenv resolves the URL at runtime — no value is baked in at generation timeSiteDdevSettingsFileto the.envpath so DDEV internals (allowed paths, gitignore) handle it correctlyconfig/application.php(Bedrock's main config, absent from standard WordPress)isWordpressAppexcludes Bedrock projects so auto-detection works correctly for installed Bedrock sites (mirrors theIsWSL2/IsWSL2MirroredModepattern)wp-bedrockto thewpglobal command'sProjectTypessoddev wpworkshookDefaultComments: getWordpressHookssoddev configsuggests WordPress hooksdocs/tests/wp-bedrock.batsManual Testing Instructions
Fresh Bedrock install
https://ddev--8219.org.readthedocs.build/en/8219/users/quickstart/#wordpress-bedrock
Verify:
wp-bedrock(check.ddev/config.yaml)web.envcontains#ddev-generated, hardcoded DB credentials (db/db/db/db), andWP_HOME="${DDEV_PRIMARY_URL}"— not a hardcoded URLddev wp core versionworks (confirmsddev wpis available for this project type)https://my-wp-bedrock-site.ddev.site/wp/wp-admin/redirects to/wp/wp-login.phpwhen unauthenticatedadmin/adminreaches the DashboardAuto-detection on existing Bedrock project
Verify: project type is detected as
wp-bedrock, notwordpress.User-managed
.envRemove the
#ddev-generatedline from.env, then runddev start.Verify: DDEV warns that
.envis user-managed and does not overwrite it.ddev import-filesVerify: file appears at
web/app/uploads/test.txt.Automated Testing Overview
docs/tests/wp-bedrock.bats— runs the full quickstart, validates site loads, wp-admin redirects to login, and a real cookie-based login reaches the Dashboardpkg/ddevapp/settings_test.go—TestWriteSettingsverifies the.envis written with#ddev-generatedpkg/ddevapp/apptypes_test.go—TestConfigOverrideActioncoverswp-bedrockpkg/ddevapp/testdata/TestDetectAppType/wp-bedrock/—TestDetectAppTypepicks up the fixture automaticallyRelease/Deployment Notes
wp-bedrock— no impact on existingwordpressprojectswordpresswill now auto-detect aswp-bedrockwhenddev configis run without--project-type