0

I'm currently attempting to use XDebug 2.2.1 and PHPStorm 7.1 to debug my WordPress plugin. So far, I've successfully installed XDebug and breakpoints are working fine. However, I'm unable to access any of the variables being used in the functions in which I'm breaking.

For instance, I break in this code:

function generateGoalCard($sub) {
        $goalID = $this->CodeLibrary->convertStringToInt($sub->goalID);
        $userID = $this->CodeLibrary->convertStringToInt($sub->userID);
        print('goalID: '); // BREAK POINT HERE
        // Other unimportant code ...
}

Below is a screenshot of the debugging window at the above break point. As you can see, $goalID and $userID are not accessible. How can I gain access to my plugin's variables?

enter image description here

Here's the screenshot in DropBox.

4
  • Can you evaluate what the values are using the debug Terminal when paused at that breakpoint? Commented Jun 4, 2014 at 14:39
  • @hereswhatidid: No, I'm not. In the "Evaluate Expression" window, inputting $goalID returns result = null. Commented Jun 4, 2014 at 14:41
  • I just tried putting the break point a few lines further down in the code so I could see a var_dump I was doing of $userID and then opened my page in a new tab. Again, PHPStorm catches the breakpoint but nothing is rendered in the page. I'm not knowledgable enough to know whether or not that var_dump should have been rendered in my browser before the code execution was suspended. After resuming the code, the var_dump is rendered as expected. Commented Jun 4, 2014 at 14:44
  • Note, too, that I'm using the zero-configuration debugging approach with Chrome bookmarklets, and that the file I'm breaking in is not named index.php like the Frames pane seems to believe. Commented Jun 4, 2014 at 14:52

1 Answer 1

1

My current understanding is that the problem was caused by the fact that my project only encompassed a plugin directory while the page I was debugging was generated by many php files outside the project directory.

The fix took just two changes to PHPStorm preferences:

  1. Go to PHPStorm > Preferences > Project Settings > PHP > Debug and disable Force break at the first line when no path mapping specified.
  2. Go to PHPStorm > Preferences > Project Settings > PHP > Servers and disable Use path mappings (select if the server is remote or symlinks are used.

With those two changes, it all seems to be working perfectly fine.

1
  • Dear @LeoFNaN: Thanks for the edit, but I'm on a Mac, not Windows. Reverting... Commented Oct 24, 2016 at 12:58

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.