How to debug subsequent request in Phpstorm?

PHPStorm Debug CLI to HTTP Request

  • I am trying to debug a Laravel artisan command, executed via CLI, which in turn calls an external endpoint (via Guzzle). Both the original app and the external endpoint are available locally, open in PHPStorm as two separate projects. I'm able to debug the CLI command by running this command in terminal: export XDEBUG_CONFIG="remote_enable=1 remote_mode=req remote_port=9000 remote_host=127.0.0.1 remote_connect_back=0" (or for windows): set XDEBUG_CONFIG="remote_enable=1 remote_mode=req remote_port=9000 remote_host=127.0.0.1 remote_connect_back=0" As illustrated on https://confluence.jetbrains.com/display/PhpStorm/Simultaneous+debugging+sessions+with+PhpStorm, you can execute an external script by passing a debug query string: $debuggingQuerystring = ''; if (isset($_GET['XDEBUG_SESSION_START'])) { // xdebug $debuggingQuerystring = 'XDEBUG_SESSION_START=' . $_GET['XDEBUG_SESSION_START']; } if (isset($_COOKIE['XDEBUG_SESSION'])) { // xdebug (cookie) $debuggingQuerystring = 'XDEBUG_SESSION_START=PHPSTORM'; } if (isset($_GET['start_debug'])) { // zend debugger $debuggingQuerystring = 'start_debug=' . $_GET['start_debug']; } $personJson = file_get_contents('http://127.0.0.1:778/backend.php?' . $debuggingQuerystring); The current problem that when executed via CLI, the $debugQueryString is empty. What do we pass along and how to the external url which will allow debugging on the second project? $client = new Guzzle\Http\Client($this->webhook_url); $response = $client->post('', [], $this->params)->send(); $code = $response->getStatusCode();

  • Answer:

    This was easier than I thought. $debuggingQuerystring = ''; if (isset($_GET['XDEBUG_SESSION_START'])) { // xdebug $debuggingQuerystring = 'XDEBUG_SESSION_START=' . $_GET['XDEBUG_SESSION_START']; } if (isset($_COOKIE['XDEBUG_SESSION'])) { // xdebug (cookie) $debuggingQuerystring = 'XDEBUG_SESSION_START=PHPSTORM'; } if (isset($_GET['start_debug'])) { // zend debugger $debuggingQuerystring = 'start_debug=' . $_GET['start_debug']; } if(empty($debuggingQuerystring)) { $debuggingQuerystring = 'XDEBUG_SESSION_START=PHPSTORM'; } $this->debugString = $debuggingQuerystring; And then the url call: $client = new Guzzle\Http\Client($this->webhook_url); $response = $client->post('?' . $this->debugString, [], $this->final_data)->send(); $code = $response->getStatusCode();

egekhter at Stack Overflow Visit the source

Was this solution helpful to you?

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.