roots / bedrock

WordPress boilerplate with Composer, easier configuration, and an improved folder structure

Home Page:https://roots.io/bedrock/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

WP-CLI Could not process the 'wp-config.php' transformation in Bedrock

NurdinDev opened this issue · comments

Description

I'm trying to inject a new config to wp-config.php using wp-cli by running this command wp config set S3_UPLOADS_BUCKET 'value'

Steps to reproduce

  1. Fresh bedrock project
  2. Complet WP installer
  3. Run this command for example wp config set WP_DEBUG true --raw

Expected behavior:
I expect to see the new config inside wp-config.php file as well

Actual behavior:
console error with this message

Error: Could not process the 'wp-config.php' transformation.
Reason: Unable to locate placement anchor.

Versions

Mac-Os: latest
Bedrock: 1.14.1
PHP version: 7.4.9

Two things:

  1. that command lets you set the anchor (https://github.com/wp-cli/config-command/blob/c3ed520d62e0ef93c713fff959c578ff90f6c488/src/Config_Command.php#L411-L413). Since Bedrock's wp-config.php doesn't have the normal anchor text, you could set that to a string that does exist.
  2. Bedrock's configuration model uses config/application.php and not wp-config.php so you don't want to edit that file anyway.

I don't think it's possible to tell WP-CLI to look for a different file unfortunately.

commented

Hi,

I faced this too, but fortunately found a fix
By default the wp config set command adds the rule just before "/* That's all, stop editing!".
If your config file is missing that line then it may cause issues

The workaround is to either pass another --anchor or add the missing line.

/* That's all, stop editing! Happy publishing. */