Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to enable Xdebug Remote Session in Async Request? #28

Open
dreeh opened this issue Mar 18, 2019 · 4 comments
Open

How to enable Xdebug Remote Session in Async Request? #28

dreeh opened this issue Mar 18, 2019 · 4 comments

Comments

@dreeh
Copy link

dreeh commented Mar 18, 2019

Is there a possibility to activate debug session with xdebug in fired async request?
I've tried to set XDEBUG_SESSION_START POST var and some environment settings, but without success.

Did anyone found a solution?

@hollodotme
Copy link
Owner

hollodotme commented Mar 18, 2019

@dreeh Thank's for the question.

I have some too: 😄

  • Is the php-fpm endpoint on the same machine as your caller or on a different one?
  • Can you provide your Xdebug ini settings from the php-fpm endpoint?
  • Can you provide some info about your setup (OS, vagrant box, docker(-compose) config, local machine, PHP version, Xdebug Version, version of this library)?
  • Can you provide a snippet of your calling code using the Client & PostRequest classes from this library? (I'd like to see how you call the endpoint)

@bcremer
Copy link

bcremer commented Mar 18, 2019

Are you using Xdebug's remote_connect_back feature? If so please note that you also have to set the HTTP_X_FORWARDED_FOR-header in the fpm-request.

@mfuehrer82
Copy link

I use following configuration in xdebug.ini and debugging works well with multiple session.

zend_extension=xdebug.so
xdebug.default_enable=1
xdebug.remote_enable=1
xdebug.remote_host=${HOST_IP}
xdebug.remote_port=10000
xdebug.remote_autostart=1
xdebug.idekey=PHPSTORM
xdebug.remote_log=/tmp/xdebug-remote.log

You have to ensure that your IDE also use port 10000 for incoming connection.
There is a client example where you can find all settings

@dreeh
Copy link
Author

dreeh commented Mar 19, 2019

@mfuehrer82 : this is not very helpful. Is there no special thing needed to start debugging in (sub)request?

@hollodotme :

PHPStorm is starting debug session in main thread, but not in request.

  • Is the php-fpm endpoint on the same machine as your caller or on a different one?

Yes, all is on the same machine.

  • Can you provide your Xdebug ini settings from the php-fpm endpoint?

zend_extension = /usr/lib/php/20160303/xdebug.so
debug.idekey = phpstorm-xdebug
xdebug.remote_connect_back = On
xdebug.remote_enable = On
xdebug.remote_handler = dbgp
xdebug.remote_host = 127.0.0.1
xdebug.remote_log = "/var/log/xdebug.log"
xdebug.remote_port = 9000

  • Can you provide some info about your setup (OS, vagrant box, docker(-compose) config, local machine, PHP version, Xdebug Version, version of this library)?

PHP 7.1.26-2+020190216175258.13+jessie1.gbpc20626 (cli) (built: Feb 16 2019 23:23:24) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.1.26-2+020190216175258.13+jessie1.gbpc20626, Copyright (c) 1999-2018, by Zend Technologies
with Xdebug v2.6.1, Copyright (c) 2002-2018, by Derick Rethans

Debian, no docker, no vagrant:

Distributor ID: Debian
Description: Debian GNU/Linux 8.11 (jessie)
Release: 8.11
Codename: jessie

  • Can you provide a snippet of your calling code using the Client & PostRequest classes from this library? (I'd like to see how you call the endpoint)

      $content = http_build_query(
          [
              'XDEBUG_SESSION_START' => 'phpstorm-xdebug'
          ]
      );
    
      $request = new PostRequest(..., $content);
      $request->setCustomVar('PHP_IDE_CONFIG', getenv('PHP_IDE_CONFIG'));
      $request->setCustomVar('XDG_SESSION_ID', getenv('XDG_SESSION_ID'));
      $request->setCustomVar('SSH_CLIENT', getenv('SSH_CLIENT'));
      $request->setCustomVar('SSH_CONNECTION', getenv('SSH_CONNECTION'));
      $request->setCustomVar('XDG_RUNTIME_DIR', getenv('XDG_RUNTIME_DIR'));
      $request->setCustomVar('XDEBUG_CONFIG', 'idekey=phpstorm-xdebug');
      $request->setCustomVar('XDEBUG_SESSION_START', 'phpstorm-xdebug');
      $request->setCustomVar('HTTP_X_FORWARDED_FOR', '172.29.9.149');
      $request->setCustomVar('REMOTE_ADDR', '172.29.9.149');
    
      $connection = new UnixDomainSocket(...);
      $client = new hollodotme\FastCGI\Client($connection);
      $client->sendAsyncRequest($request);
    

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants