fast-cgi-client
fast-cgi-client copied to clipboard
How to enable Xdebug Remote Session in Async Request?
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?
@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&PostRequestclasses from this library? (I'd like to see how you call the endpoint)
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.
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
- https://github.com/mfuehrer82/fast-cgi-client-example
@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+0~20190216175258.13+jessie~1.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+0~20190216175258.13+jessie~1.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);