WordPress Bedrock "WP_HOME" not defined (.env missing) in CI
Bedrock loads configuration from a .env file and validates that required keys exist. .env is gitignored, so a fresh CI checkout has none, and the Dotenv validator throws because WP_HOME and other required variables are undefined.
What this error means
Bootstrapping WordPress under Bedrock fails with "Dotenv\Exception\ValidationException: One or more environment variables failed assertions: WP_HOME is missing, DB_NAME is missing".
PHP Fatal error: Uncaught Dotenv\Exception\ValidationException: One or more
environment variables failed assertions: WP_HOME is missing, WP_SITEURL is missing,
DB_NAME is missing in /var/www/vendor/vlucas/phpdotenv/src/Validator.phpCommon causes
The .env file is gitignored and absent in CI
Bedrock keeps secrets out of git, so the runner checkout has no .env, and Dotenv::required() fails for every expected key.
Required keys are set but not exported to the process
Variables exist in the workflow but were not written to .env or exported, so Bedrock's validator does not see them.
How to fix it
Generate .env from CI secrets
- Define WP_HOME, WP_SITEURL, and DB_* as CI secrets or env.
- Write them into a
.envat the project root before any wp call. - Re-run so Bedrock's Dotenv validation passes.
cat > .env <<'EOF'
WP_HOME=http://localhost
WP_SITEURL=${WP_HOME}/wp
DB_NAME=wordpress
DB_USER=root
DB_PASSWORD=root
DB_HOST=127.0.0.1
EOFExport the variables to the environment instead
phpdotenv reads existing environment variables; set them in the step env so the validator finds them without a file.
env:
WP_HOME: http://localhost
WP_SITEURL: http://localhost/wp
DB_NAME: wordpressHow to prevent it
- Render
.envfrom secrets at the start of every Bedrock CI job. - Keep the required-key list in sync between
config/and CI. - Never commit
.env; provide it per-environment in CI.