Debugging PHP code is part of any project, but WordPress comes with specific debug systems designed to simplify the process as well as standardize code across the core, plugins, and themes
When developing a WordPress site, on your local or development environment, its imperative to have the debug log turned on, in order to catch any errors/warnings before shipping the code further. Its quite easy to do, by simply setting these constants in wp-config.php
:
define( 'WP_DISABLE_FATAL_ERROR_HANDLER', true ); // WP 5.2 and later
define( 'WP_DEBUG', true );
define( 'WP_DEBUG_DISPLAY', false );
define( 'WP_DEBUG_LOG', true );
define( 'SCRIPT_DEBUG', true );
NOTE: You must insert this BEFORE /* That’s all, stop editing! Happy blogging. */ in the wp-config.php file.
The purpose of this is to
wp-content/debug.log
so that you can tail it locally and be aware of any error or warning that occurs when running the site.To learn more about these constants (and a few more) that we can define in wp-config.php
please refer WordPress Codex page for debugging.