wordpress
wordpress copied to clipboard
Add WP_DEBUG_LOG and SCRIPT_DEBUG to Docker Env variables
I like running WP files as readonly and managing their configuration with Docker Env variables. WP_DEBUG_LOG and SCRIPT_DEBUG are two WP constants that are important to set if I want to debug code. I will especially need WP_DEBUG_LOG to make sure production errors are logged but not shown to visitors. Right now, the package allows for an env variable to be passed through for WP_DEBUG but not these other two important debugging parameters.
I would suggest using WORDPRESS_CONFIG_EXTRA for this (you provide it arbitrary PHP code that gets evaluated as part of wp-config-docker.php).
I would suggest using
WORDPRESS_CONFIG_EXTRAfor this (you provide it arbitrary PHP code that gets evaluated as part ofwp-config-docker.php).
I think the problem is the php error when trying to "redefine" the constants. Having a look into the wp-config.php inside the container reveals that you have the option to define your config via WORDPRESS_CONFIG_EXTRA:
// (we include this by default because reverse proxying is extremely common in container environments)
if ($configExtra = getenv_docker('WORDPRESS_CONFIG_EXTRA', '')) {
eval($configExtra);
}
define( 'WP_DEBUG', true );
define( 'WP_DEBUG_LOG', true );
define( 'SCRIPT_DEBUG', true );
define( 'SAVEQUERIES', true );
define( 'WP_DEBUG_DISPLAY', false );
/* That's all, stop editing! Happy publishing. */
but trying to redefine a constant is still an error which shows with the wp-debugging plugin:

It would be nice if those can be overwritten by ENV variables like those lines:
define( 'DB_HOST', getenv_docker('WORDPRESS_DB_HOST', 'mysql') );
Those extra define lines aren't from our config file:
https://github.com/docker-library/wordpress/blob/f7f171e0e6bec88ffa0edd58ca1c512d286ab18d/wp-config-docker.php#L121-L125
Those extra
definelines aren't from our config file:https://github.com/docker-library/wordpress/blob/f7f171e0e6bec88ffa0edd58ca1c512d286ab18d/wp-config-docker.php#L121-L125
Sorry I just realized that one of those plugins: "debug-bar, query-monitor, wp-debugging" are injecting those ENV vars. Should work as expected then. 👍
Closing as this seems solved.