Skip to content

feat: add wp-bedrock project type, fixes #8179#8219

Merged
rfay merged 18 commits intoddev:mainfrom
jonesrussell:20250311_jonesrussell_bedrock_project_type
Apr 15, 2026
Merged

feat: add wp-bedrock project type, fixes #8179#8219
rfay merged 18 commits intoddev:mainfrom
jonesrussell:20250311_jonesrussell_bedrock_project_type

Conversation

@jonesrussell
Copy link
Copy Markdown
Contributor

@jonesrussell jonesrussell commented Mar 11, 2026

The Issue

Adds first-class support for Bedrock as a DDEV project type, so users can run ddev config --project-type=wp-bedrock instead of manually configuring WordPress with docroot and .env overrides.

How This PR Solves The Issue

  • Adds AppTypeWPBedrock constant (wp-bedrock) and registers it in the appTypeMatrix after wordpress alphabetically
  • Implements wpBedrockConfigOverrideAction to auto-set docroot to web
  • Writes a DDEV-managed .env from an embedded static asset (wordpress/bedrock/bedrock.env) via settingsCreator, using WP_HOME="${DDEV_PRIMARY_URL}" so phpdotenv resolves the URL at runtime — no value is baked in at generation time
  • Sets SiteDdevSettingsFile to the .env path so DDEV internals (allowed paths, gitignore) handle it correctly
  • Detection via config/application.php (Bedrock's main config, absent from standard WordPress)
  • isWordpressApp excludes Bedrock projects so auto-detection works correctly for installed Bedrock sites (mirrors the IsWSL2/IsWSL2MirroredMode pattern)
  • Adds wp-bedrock to the wp global command's ProjectTypes so ddev wp works
  • Adds hookDefaultComments: getWordpressHooks so ddev config suggests WordPress hooks
  • Updates quickstart docs and adds docs/tests/wp-bedrock.bats

Manual Testing Instructions

Fresh Bedrock install

https://ddev--8219.org.readthedocs.build/en/8219/users/quickstart/#wordpress-bedrock

mkdir -p ~/tmp/my-wp-bedrock-site && cd ~/tmp/my-wp-bedrock-site
ddev config --project-type=wp-bedrock
ddev start
ddev composer create-project roots/bedrock
ddev wp core install --url='$DDEV_PRIMARY_URL' --title='My Bedrock Site' --admin_user=admin --admin_password=admin [email protected]
ddev launch /wp/wp-admin/

Verify:

  • Project type is wp-bedrock (check .ddev/config.yaml)
  • Docroot is auto-set to web
  • .env contains #ddev-generated, hardcoded DB credentials (db/db/db/db), and WP_HOME="${DDEV_PRIMARY_URL}" — not a hardcoded URL
  • ddev wp core version works (confirms ddev wp is available for this project type)
  • Site loads at https://my-wp-bedrock-site.ddev.site
  • /wp/wp-admin/ redirects to /wp/wp-login.php when unauthenticated
  • Login with admin/admin reaches the Dashboard

Auto-detection on existing Bedrock project

cd ~/tmp/my-wp-bedrock-site
ddev config  # no --project-type flag

Verify: project type is detected as wp-bedrock, not wordpress.

User-managed .env

Remove the #ddev-generated line from .env, then run ddev start.

Verify: DDEV warns that .env is user-managed and does not overwrite it.

ddev import-files

mkdir -p /tmp/test-uploads && echo "test" > /tmp/test-uploads/test.txt
ddev import-files --source=/tmp/test-uploads

Verify: 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 Dashboard
  • pkg/ddevapp/settings_test.goTestWriteSettings verifies the .env is written with #ddev-generated
  • pkg/ddevapp/apptypes_test.goTestConfigOverrideAction covers wp-bedrock
  • pkg/ddevapp/testdata/TestDetectAppType/wp-bedrock/TestDetectAppType picks up the fixture automatically

Release/Deployment Notes

  • New project type wp-bedrock — no impact on existing wordpress projects
  • Existing Bedrock projects previously configured as wordpress will now auto-detect as wp-bedrock when ddev config is run without --project-type

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Mar 11, 2026

@jonesrussell jonesrussell force-pushed the 20250311_jonesrussell_bedrock_project_type branch from c1ac843 to 84ddfef Compare March 11, 2026 07:00
@jonesrussell jonesrussell marked this pull request as ready for review March 11, 2026 07:00
@jonesrussell jonesrussell requested review from a team as code owners March 11, 2026 07:00
Copy link
Copy Markdown
Member

@rfay rfay left a comment

Choose a reason for hiding this comment

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

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)

@rfay rfay marked this pull request as draft March 11, 2026 16:57
@rfay rfay marked this pull request as draft March 11, 2026 16:57
@stasadev
Copy link
Copy Markdown
Member

https://github.com/ddev/ddev/actions/runs/22970758591/job/66686551435#step:8:163

Command 'wp' is not available for the 'wp-bedrock' project type, skipping /home/runner/.ddev/commands/web/wp.

@jonesrussell jonesrussell force-pushed the 20250311_jonesrussell_bedrock_project_type branch from 96cf8dd to 9387e9d Compare March 23, 2026 18:52
@rfay rfay marked this pull request as ready for review April 3, 2026 17:45
@rfay rfay force-pushed the 20250311_jonesrussell_bedrock_project_type branch from 9387e9d to ff417e1 Compare April 3, 2026 17:45
Copy link
Copy Markdown
Member

@rfay rfay left a comment

Choose a reason for hiding this comment

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

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.

Comment thread docs/content/users/quickstart.md
Comment thread pkg/ddevapp/wp_bedrock.go Outdated
Comment thread pkg/ddevapp/wp_bedrock.go
@rfay
Copy link
Copy Markdown
Member

rfay commented Apr 3, 2026

Claude comments

.env management timing — confirmed OK

ddev composer create-project calls prepareAppForComposer() (composer-create-project.go:561-588) which invokes app.PostStartAction() after rsyncing files. So wpBedrockPostStartAction runs after .env.example exists — the .env file will be correctly configured before wp core install.

Issues found

1. Alphabetical ordering in values.go (minor)

AppTypeWPBedrock is placed between backdrop and cakephp in values.go:92. The string value "wp-bedrock" should sort after "wordpress". Same issue in apptypes.go:94 — the map entry is between backdrop and cakephp.

2. Auto-detection order concern (minor, likely OK in practice)

DetectAppType iterates types in sort.Strings order (apptypes.go:440). Since "wordpress" sorts before "wp-bedrock", if both detectors match, WordPress would win. In practice this is OK because with an empty docroot, isWordpressApp won't find wp-settings.php (it's at web/wp/wp-settings.php, two levels deep), while isWPBedrockApp correctly finds config/application.php at root. But if someone manually sets docroot=web, WordPress detection could win since wp-settings.php would be one level below docroot. Worth considering whether isWordpressApp should exclude Bedrock projects, or whether this is fine since the quickstart always uses explicit --project-type=wp-bedrock.

3. No WP_SITEURL set in .env (OK but worth noting)

The old quickstart explicitly set WP_SITEURL=${WP_HOME}/wp. The new wpBedrockPostStartAction only sets WP_HOME. This works because Bedrock's config/application.php defaults WP_SITEURL to WP_HOME . '/wp', but it means users who customize WP_SITEURL in .env won't have it auto-managed by DDEV.

Summary

The PR is well-structured. The core logic in wp_bedrock.go is clean — .env management via postStartAction is a good approach. The quickstart docs simplification (removing manual .env steps) is a nice UX improvement.

Should-fix:

  • Move AppTypeWPBedrock and its apptypes.go entry to sort after wordpress alphabetically (consistency with the rest of the codebase)

Worth considering:

  • The auto-detection order: if a user has a fully installed Bedrock project and runs ddev config without --project-type, the result depends on whether isWordpressApp also matches. May want to add an exclusion in isWordpressApp for Bedrock projects, or document that --project-type=wp-bedrock should always be specified explicitly.

@rfay
Copy link
Copy Markdown
Member

rfay commented Apr 3, 2026

Should ddev import-files work here by default? Does it?

@rfay rfay requested review from nickchomey and stasadev April 3, 2026 17:54
@rfay rfay force-pushed the 20250311_jonesrussell_bedrock_project_type branch from ff417e1 to 93a86c0 Compare April 3, 2026 17:59
@jonesrussell
Copy link
Copy Markdown
Contributor Author

Verified via Claude Code review — built the PR binary and tested ddev import-files against a real Bedrock project.

What I did:

  1. Built the binary from commit 93a86c0 (head of this PR)
  2. Created a fresh project: ddev config --project-type=wp-bedrock && ddev start
  3. Installed Bedrock: ddev composer create-project roots/bedrock
  4. Created test files in /tmp/test-import-files/ and ran ddev import-files --source=/tmp/test-import-files

Result: ddev import-files works by default. Files are imported to web/app/uploads/ as expected.

The PR wires this up in apptypes.go with:

  • uploadDirs: getWPBedrockUploadDirs — returns ["app/uploads"] (Bedrock moves wp-content to app/ inside docroot)
  • importFilesAction: wordpressImportFilesAction — reuses the standard WordPress import logic

These combine to resolve the destination as <docroot>/app/uploads = web/app/uploads, which is the correct Bedrock upload path.

@jonesrussell jonesrussell force-pushed the 20250311_jonesrussell_bedrock_project_type branch from 93a86c0 to 8a34cdb Compare April 5, 2026 21:58
@stasadev stasadev changed the title feat: add bedrock project type feat: add bedrock project type, fixes #8179 Apr 6, 2026
@jonesrussell jonesrussell force-pushed the 20250311_jonesrussell_bedrock_project_type branch from 8a34cdb to 9f1cd3b Compare April 8, 2026 19:48
@rfay rfay self-requested a review April 8, 2026 22:59
@rfay rfay force-pushed the 20250311_jonesrussell_bedrock_project_type branch 2 times, most recently from e605024 to 90e19c1 Compare April 9, 2026 15:17
Copy link
Copy Markdown
Member

@rfay rfay left a comment

Choose a reason for hiding this comment

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

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

@rfay rfay force-pushed the 20250311_jonesrussell_bedrock_project_type branch from 46cd583 to 78ba236 Compare April 9, 2026 18:17
@stasadev stasadev changed the title feat: add bedrock project type, fixes #8179 feat: add wp-bedrock project type, fixes #8179 Apr 10, 2026
@stasadev
Copy link
Copy Markdown
Member

I don't like that we take over the .env file here.

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.

@stasadev
Copy link
Copy Markdown
Member

Use $DDEV_PRIMARY_URL in .env

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.

@rfay
Copy link
Copy Markdown
Member

rfay commented Apr 10, 2026

It's OK to go back to the previous setup with generated .env instead of packaged .env

jonesrussell and others added 15 commits April 10, 2026 15:43
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]>
…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]>
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]>
@stasadev stasadev force-pushed the 20250311_jonesrussell_bedrock_project_type branch from 78ba236 to 217a401 Compare April 10, 2026 12:46
@stasadev
Copy link
Copy Markdown
Member

It's OK to go back to the previous setup with generated .env instead of packaged .env

We would need to maintain the whole file, so if Bedrock adds something new in there, then our code won't reuse .env.example.

I updated the logic, and now .env also updates these env (only on the first cp .env.example .env):

# 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'

Copy link
Copy Markdown
Member

@stasadev stasadev left a comment

Choose a reason for hiding this comment

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

Looks good to me.

Copy link
Copy Markdown
Member

@rfay rfay left a comment

Choose a reason for hiding this comment

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

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.

@rfay rfay merged commit 9606881 into ddev:main Apr 15, 2026
37 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bedrock is a different project type. Break it out from wordpress type

3 participants