Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why are variables not showing in the debug window in PhpStorm?

I have Xdebug working, I can stop at and step through breakpoints. But the variables that it has already reached do not show up in the Variables window. See the picture - variables $test and $test2 do not show up.

enter image description here

My config in php.ini is

[XDebug]
zend_extension = /usr/lib/php/20170718/xdebug.so
xdebug.remote_host = 127.0.0.1
xdebug.remote_port = 10000
xdebug.remote_mode = req
xdebug.remote_enable = 1
xdebug.remote_autostart = 1
xdebug.idekey = "PHPSTORM"
like image 908
Michael Millar Avatar asked May 30 '18 19:05

Michael Millar


People also ask

How do I show Debug variables in IntelliJ?

You can click on the Run icon in the gutter area and select the Debug option. You can invoke context actions on the class or main method by using Alt+Enter and choose the Debug action. You can also start it from the Run menu, or by pressing Shift F9.

How do I change the value of a variable in Debug mode in IntelliJ?

Select a variable or a property of a complex object in the Debug window, press F2 or right-click and choose Set Value... from the context menu, and then specify a new value and press Enter .

How can you examine a variable while executing code?

You can click in the editable line under the name column and type in the variable name whose value you want to see. Or you can right click on variables from your code editor and select “Add to Watch”. Beyond adding just a single variable, you can type in generally any expression.


2 Answers

I've been banging my head against my desk with the very issue myself for the past few days. Running things in CLI mode (when running tests for example) was fine, but trying to view a site in the browser and getting it to hit a breakpoint, I wasn't seeing any locally initialised variables either.

The issue it appears is the OpCache module. This seems to do some internal optimisations and the vars become non-visible to the Xdebug stack.

Disable the OpCache module by removing the symlink in the PHP modules config and you're able to see the local vars as expected.

I have this running on the latest PHP 7.2 (FPM) on an Ubuntu image in a Docker container.

HTH =)

like image 109
Ian.H Avatar answered Oct 02 '22 05:10

Ian.H


I had similar problem. It happened that php version was 7.2 but extensions were installed for 7.1 version by Dockerfile.

like image 42
Dmitrij Rebrov Avatar answered Oct 02 '22 05:10

Dmitrij Rebrov