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 for 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
The 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, WP_DEBUG_LOG
is set to false and cannot be overridden.
By default,
and WP_DEBUG_DISPLAY
are not defined and as a result, will load as WP_DEBUG
false
unless overridden.
Even if overridden and defined as true
, WP_DEBUG_DISPLAY
(and WP_DEBUG_LOG
) will perform no function unless
is also defined as WP_DEBUG
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, and configurations should not be set to enable WP_DEBUG_DISPLAY
unless the production environment 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 PHP 7.4, 8.0, or 8.1.
Logging
On local environments and non-production environments, WP_DEBUG
is defined as true
in the VIP Skeleton codebase to make PHP Deprecations, Notices, Warnings, and Errors available during development.
For WP_DEBUG_LOG
to function as expected, both WP_DEBUG
and WP_DEBUG_LOG
must be defined as true
.
- On a VIP Platform environment, where
WP_DEBUG_LOG
is alwaysfalse
, logged error output will be retrievable in the VIP Dashboard Health: Logs panel or with the VIP-CLI Runtime Logs command. - 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
.
Last updated: September 21, 2023