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
Related Q & A:
- How can you view an HTTP request in transit?Best solution by Information Security
- How to debug a core file without debug symbols?Best solution by Stack Overflow
- How to debug HTTP request?Best solution by Server Fault
- How can I send an http request at a specific time?Best solution by Stack Overflow
- How to do remote debug in PHPstorm with xdebug?Best solution by Stack Overflow
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
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.