1

I try to do parallel debugging. I use PhpStorm debugging tutorial (about 30 minute and more) with frontend.php and backend.php files:

frontend.php file:

<?php

$personJson = file_get_contents('http://localhost:777/projects/debug-both/backend.php/backend.php');
$person = json_decode($personJson);

var_dump($person);

backend.php file:

<?php

class Person {
    public $name;
    public $email;
}

$person = new Person();

$person->name = 'Something';
$person->email = '[email protected]';

echo json_encode($person);

I use zero configuration method. When I launch frontend file in browser with debug session, in PhpStorm debugging session is being start but I cannot step over in line:

file_get_contents('http://localhost:777/projects/debug-both/backend.php/backend.php');

to go to the backend.php file as in tutorial (31:36 in the video).

Question: how to make it working? In this video there is nothing more and it seems it should work right away but it doesn't.

I include my xdebug configuration from phpinfo xdebug configuration from phpinfo and xdebug configuration in PhpStorm xdebug configuration in PhpStorm

2
  • So .. you are trying to debug more than one request at the same time (1st script calls 2nd, and you want to debug it as well). Is that correct? If so -- show your xdebug settings (xdebug section of phpinfo() output) as well as screenshot of "Settings | PHP | Debug" Commented Jul 1, 2014 at 8:52
  • @LazyOne Thanks you for your interest. That's exactly I want to achieve. I added screenshots to my question Commented Jul 1, 2014 at 9:14

1 Answer 1

5

1. Settings | PHP | Debug | Max simultaneous connections -- should be more than 1. You already have it set.

2. xdebug.remote_autostart should be 1 / on. This will tell xdebug to attempt to debug every single request regardless of debug cookie/parameter.

This is needed as your 2nd script will not receive the same cookies/parameters as original script (as it is technically separate request).

Yes, this option may not convenient for day-to-day development as it will attempt to debug every single request, and if debug client is not available ... you will see around 1 sec delay in script execution.

The alternative approach (in your specific case) would be adding xdebug GET parameter (e.g. ?XDEBUG_SESSION_START=1) into URL when calling for 2nd script. This will tell xdebug to debug this request. For example:

file_get_contents('http://localhost:777/projects/debug-both/backend.php/backend.php?XDEBUG_SESSION_START=1');

As you can see this approach requires modifying your code (requested URLs). Quite often this is not desired.

Yet another alternative is to set breakpoint programmatically by adding xdebug_break();. This should trigger debugger even without those extra params/cookies or remote_autostart setting.

The downside is the same: code manipulation is required. The good point -- it should be easier to do compared to altering URLs (+ much easier to read/understand what is going on).

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you very much for very detailed answer. In my case changing xdebug.remote_autostart was the thing I needed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.