Open kirtangajjar opened 6 years ago
debug an error on production server
That is not really a good practice and should be avoided entirely. But yes, support for enabling/disabling xdebug can be added which will be pretty useful in development.
Update: It seems getting xdebug to work has become really easy with xdebug 3. Instructions shown in this video work as-is without any modifications. The video was taken from official documentation.
Adding steps here:
xdebug.ini
zend_extension=xdebug.so
xdebug.mode=develop,debug
xdebug.start_with_request=yes
xdebug.discover_client_host=0
xdebug.client_host=host.docker.internal
docker-compose.yml
:
extra_hosts:
- "host.docker.internal:host-gateway"
I followed them and I was able to trigger a breakpoint.
Syntax of the command can be like:
ee site debug enable
ee site debug disable
ee site debug enable --php
Enables debugging only in PHP. No changes will be made to wp-config.php
ee site debug enable --wp
--php flag is implied here. Enables debugging in WP. Following lines will be added in wp-config.php.
define( 'WP_DEBUG', true );
define( 'WP_DEBUG_LOG', true );
define( 'WP_DEBUG_DISPLAY', false );
@ini_set( 'display_errors', 0 );
ee site debug enable --assets
This implies --wp and following lines will be added in wp-config.php
define( 'SCRIPT_DEBUG', true );
ee site debug enable --query
This implies --wp and following lines will be added in wp-config.php
define( 'SAVEQUERIES', true );
ee site debug enable --display-errors
This implies --wp and following lines will be added in wp-config.php
define( 'WP_DEBUG_DISPLAY', true );
@ini_set( 'display_errors', 1 );
ee site debug enable --plugins
Will install query-monitor
and debug-bar
plugins.
Does query-monitor
work without define( 'SAVEQUERIES', true );
?
What happens when nothing is passed to ee site debug enable
?
There are instances when we would need to debug an error on production server. At such times, we need to manually modify config files to enable xdebug.
Since v4 will be docker based, we can enable/disable xdebug pretty easily. In the container that we have to enable xdebug, we need to copy a
xdebug.ini
file to/usr/local/etc/php/conf.d
and expose port9000
of the container.We can have a flag like
ee site <sitename> --enable-xdebug
andee site <sitename> --disable-xdebug
to toggle xdebug.