EasyEngine / feature-requests

A repo to track all feature requests on EasyEngine project using issue tracker.
5 stars 2 forks source link

Consider adding support for enabling/disabling xdebug on a particular site #60

Open kirtangajjar opened 6 years ago

kirtangajjar commented 6 years ago

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 port 9000 of the container.

We can have a flag like ee site <sitename> --enable-xdebug and ee site <sitename> --disable-xdebug to toggle xdebug.

mbtamuli commented 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.

kirtangajjar commented 2 years ago

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:

  1. Add following to 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
  2. Add following to docker-compose.yml:
    extra_hosts:
      - "host.docker.internal:host-gateway"
  3. Restart PHP
  4. Enable Listen for xdebug connection on IDE
  5. Add breakpoint
  6. Visit site in browser

I followed them and I was able to trigger a breakpoint.

kirtangajjar commented 2 years ago

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.

rahul286 commented 2 years ago

Does query-monitor work without define( 'SAVEQUERIES', true );?

What happens when nothing is passed to ee site debug enable?