I’m looking to toggle the WP_DEBUG value within a WP-CLI script.
Is there any option doing so AFTER the wp-config.php file was created?
(I know we can add extra PHP when creating the wp-config.php file, but once that’s done, is there a way to turn off the WP_DEBUG state during the script?)
Thanks.
Woohoo! Native support added since WP-CLI version 1.5 –
https://developer.wordpress.org/cli/commands/config/set/
Example:
To extend on @tlt2w answer posted above, I’m using this combo:
You could use
wp config get
to determine if debug is enabled or not, however today there is no way to set that value via WP-CLI.That said, just wrote a bash command that can toggle the value for you.
You can run it in the same directory you have your
wp-config.php
:Every time you run it, the
WP_DEBUG
constant value will switch fromtrue
tofalse
or vice-versa.Unfortunately there is no way to toggle the
WP_DEBUG
value during the script execution, since the value was already defined inwp-config.php
file.