How to Enable WordPress Debugging Using WP-CLI

Although it is more secure to disable errors from displaying on your website, at times, it may be necessary to enable debugging. Enabling debugging errors can help you to diagnose and resolve issues with your website. In this guide, you can learn how to check, enable, and disable debugging using WP-CLI.

Check Debugging Status

Using the wp config list command, you can determine if the WP_DEBUG constant is set to true (enabled) or false (disabled).

  1. SSH into your server as the user that will be running WP-CLI.
  2. Use the cd command to switch to the document root directory of your website.Example: cd public_html
  3. Run the following command:wp config list WP_DEBUG

The following output will be displayed once the command finishes running:

[email protected] [~/public_html]# wp config list WP_DEBUG +----------+-------+----------+ | name     | value | type     | +----------+-------+----------+ | WP_DEBUG | false | constant | +----------+-------+----------+

Enable Debugging

The WP-CLI command wp config allows you to generate a wp-config.php file, list variables, constants, and file includes defined in the wp-config.php file, set the value of a specific constant or variable defined in wp-config.php file and more. In this section you can learn how to set WP_DEBUG to true to enable debugging mode for WordPress.

  1. SSH into your server as the user that will be running WP-CLI.
  2. Use the cd command to switch to the document root directory of your website.Example: cd public_html
  3. wp config set WP_DEBUG true

The following output will be displayed once the command finishes running:
[email protected] [~/public_html/wordpress]# wp config set WP_DEBUG true Success: Updated the constant 'WP_DEBUG' in the 'wp-config.php' file with the value 'true'.

Congratulations! Now you know how to use WP-CLI to check, enable and disable debugging for WordPress.

Learn more about WP-CLI, the command-line interface for WordPress, and streamline your WordPress maintenance workflow!

JB
John-Paul Briones

John-Paul is an Electronics Engineer that spent most of his career in IT. He has been a Technical Writer for InMotion since 2013.

More Articles by John-Paul

Was this article helpful? Let us know!