Skip to content

PHP error reporting

Output from PHP error reporting can be helpful for debugging issues in application code.

Settings for reporting levels

PHP error reporting levels for WordPress environments on the VIP Platform are defined by platform-level settings, WordPress Core, and custom settings added to application code. 

A php.ini configuration file sets a default of all PHP error reporting to be enabled for a WordPress environment except for notices, deprecation notices, and strict notices:
error_reporting = E_ALL & ~E_NOTICE & ~E_DEPRECATED & ~E_STRICT

Though E_STRICT is included, it is redundant in this setting since PHP 7 reassigned all instances of E_STRICT to other levels.

When WordPress loads, it updates the PHP error reporting settings to enable:
E_CORE_ERROR | E_CORE_WARNING | E_COMPILE_ERROR | E_ERROR | E_WARNING | E_PARSE | E_USER_ERROR | E_USER_WARNING | E_RECOVERABLE_ERROR. Note that this means deprecations are not reported by default.

Based on the PHP error reporting settings with WordPress loaded, if echo error_reporting() was called in application code with no arguments, the reporting level value 4983 would be returned.

Error report output

Most default values of WordPress debugging constants can be overridden and set per-environment by defining the constants with the desired values in vip-config/vip-config.php of the branch deploying to that environment.

  • On VIP Platform environments, WP_DEBUG_LOG is set to false and cannot be overridden.
  • By default,WP_DEBUG_DISPLAY and WP_DEBUG are not defined and as a result, will load as false unless overridden.
  • Even if overridden and defined as true, WP_DEBUG_DISPLAY (and WP_DEBUG_LOG if enabled on local environments) will perform no function unlessWP_DEBUG is also defined as true.

When WP_DEBUG is defined as true, WordPress sets E_ALL (all errors, warnings, notices and deprecations). If WP_DEBUG_DISPLAY is also defined as true, the ini setting display_errors will be enabled, and error output will appear in the rendered page HTML.

For this reason, WP_DEBUG is defined as false on production environments by default. Configurations should not be set to enable WP_DEBUG_DISPLAY on a production environment unless it is unlaunched.

Other than the situational exceptions described above, there are no differences between error reporting levels for production or non-production environments—launched or unlaunched—or between environments running different versions of PHP.

Logging

Logged error output for a VIP Platform environment can be retrieved in the VIP Dashboard Runtime Logs panel or with the VIP-CLI Runtime Logs command.

Logging on local environments

VIP’s WordPress Skeleton codebase defines WP_DEBUG as true for local environments and non-production environments. This makes PHP Deprecations, Notices, Warnings, and Errors available during development.

On a VIP Local Development Environment, debugging output can be retrieved with the VIP-CLI command vip dev-env logs --slug=<site-slug> --service=php.

When using other local development applications, WP_DEBUG_LOG and WP_DEBUG must both be defined as true in order to log error output.

Last updated: December 26, 2023

Relevant to

  • WordPress