brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: wp config set WP_DEBUG true --raw edits wp-config.php without opening it

Wp-Config
~/tips/tip-wordpress-config-set-raw

wp config set WP_DEBUG true --raw

Sets a constant in wp-config.php as a real true or false value, without hand-editing the file.

Hand-editing wp-config.php over SSH is how a missing semicolon takes a site down. WP-CLI can do the edit for me.

The wp config set command writes a constant into the file. The one flag to remember is --raw. Without it, WP-CLI wraps the value in quotes, and 'true' as a string is not the boolean you meant.

wp config set WP_DEBUG true --raw
wp config get WP_DEBUG
wp config set WP_MEMORY_LIMIT 256M

The first line sets a real boolean. The second reads it back. The third sets a string on purpose, so no --raw there. If the constant does not exist yet, WP-CLI adds it above the “stop editing” comment, which is the right place.

Use wp config set --no-add if you only want to change something that already exists and fail otherwise. That helps in scripts, where a typo in the name should be an error, not a new constant.

The caveat: this edits the live file. I would take a copy of wp-config.php first, and I would not use it for anything fancy such as a value built with PHP code. The command is made for plain constants and variables.

Further reading: wp config set (WP-CLI command reference), On this site: wp option list –autoload=on –format=total_bytes shows what every page load drags along, On this site: –skip-plugins and –skip-themes get WP-CLI working on a broken site

More Wp-Config tips ls -ld wp-content wp-content/plugins index.php define( 'WP_TEMP_DIR', '/var/www/example.com/tmp' ); define( 'CONCATENATE_SCRIPTS', false ); define( 'CORE_UPGRADE_SKIP_NEW_BUNDLED', true ); define( 'ALTERNATE_WP_CRON', true ); All Wp-Config tips (7) All topics

Link