PHPStorm调试CLI到HTTP请求

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 PHPStorm docs, 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();

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();