WP-CLI Could not process the 'wp-config.php' transformation in Bedrock
NurdinDev opened this issue · comments
- I've read the guidelines for Contributing to Roots Projects
- This request isn't a duplicate of an existing issue
- I've read the docs and followed them (if applicable)
- This is not a personal support request that should be posted on the Roots Discourse community
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
- Fresh bedrock project
- Complet WP installer
- 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:
- that command lets you set the
anchor
(https://github.com/wp-cli/config-command/blob/c3ed520d62e0ef93c713fff959c578ff90f6c488/src/Config_Command.php#L411-L413). Since Bedrock'swp-config.php
doesn't have the normal anchor text, you could set that to a string that does exist. - Bedrock's configuration model uses
config/application.php
and notwp-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.
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. */