Debug / XDEBUG not showing variables that must exist

Never had this happen in the last two years of using PHPStorm, not changed any settings but now variables that have to exist and have values are not being shown in the Variables pane and can't be evaluated in the watchlist. I've seen posts elsewhere about disabling OpCache n PHP but it's fully commented out in my PHP ini file.

In the attached scrshot you can see that $date has a value and that can only have come from $dates yet $dates is not shown and fails to evaluate in the watchlist. Same is happening with two earlier defined strings, $start and $end. This was not happening as recently as last week, I'm certain. Anyone know what's happening here?

2
6 comments

I know this post is nearly a year old, but I've just encountered an extremely similar issue.  Have you found a solution?

In my case, debug seems to properly identify the variable up in the coding window, but refuses to display the variable  down in the debugger window.

This strangeness just started today.  Debugging has been working wonderfully for the last two years.

 

 

0

@Jamesini

You can enable Xdebug log and check what it has to say once you finish with the debug session (if Xdebug reports that variable there or not). IDE displays what Xdebug reports.

 

Speaking in general: what debug is this: a web page or a CLI script?

The variable color suggests that it might be unused in the function .. and if you have OPCache enabled it can optimize your code by removing such unused variables. OPCache is usually enabled for a web pages and disabled for CLI.

Disable OPCache (ideally completely) and try debugging it this way.

0

Thanks for the prompt reply! 8^)

I'm debugging a webpage being served from a local machine.

I enabled the xdebug logs (wow!  cool!) and I cannot find any reference to the variable I'm looking for, but I can see plenty of other variables I'm expecting to see.

 

The variable wasn't used in the function because I was just setting it and (planning on) inspecting the value.  The debugger shows plenty of unused variables, such as "$two = 2;" which I use to set a breakpoint wherever I want. 

I've removed all traces of opcache in my php.in file and restarted apache.  *sigh* I'm not a devops guy...this stuff breaks my brain 8^(

Thanks for the help!  Any other ideas?

 

0

@Jamesini

You need to provide some reproducible code that another person (e.g. me or JB support team member) can try to debug on their PC. Ideally: start a brand new empty project and copy any files/code that will reproduce it.

Thing is: the code that I normally run works just fine for me (I mean: I do see all needed variables in the debugger): few Laravel projects, 1 simple framework and 1 simple WordPress site, few small old "spaghetti code" kind of projects.

What's your IDE version, Xdebug and PHP versions? Make sure you are using latest Xdebug (2.9.5) and PhpStorm (2020.1.1)

OPCache is the only thing I can think of right now (as I saw a few tickets/questions like that here and there).

I'm not sure if Xdebug settings can do something here .. but please check what options you have got there (I mean: do not configure anything special for Xdebug, just bare minimum like port number, debug enable etc -- leave the rest on their defaults)

0

I created a brand new empty project and put in some dead-simple PHP.  The debugger showed all my variables in the debugger window as expected.  This doesn't bode well for me. 

I'm working on a rather complicated Drupal 8 installation.  Sending our whole installation your way isn't really practical.

My debugging has been working great on this codebase for the last year plus.  Debugging still works-ish.  If I add the variable to the watch list, I can get it to show up in the normal debugging window with the rest of the vars.

Xdebug: 2.7.2 (I guess I should upgrade)

PHP Version 7.1.23

PhpStorm 2020.1.1
Build #PS-201.7223.96, built on April 30, 2020
Licensed to University of Washington Tacoma / My Privacy 8^)
Subscription is active until September 10, 2020
Runtime version: 11.0.6+8-b765.40 x86_64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
macOS 10.14.6
GC: ParNew, ConcurrentMarkSweep
Memory: 1981M
Cores: 8
Registry: run.processes.with.pty=TRUE
Non-Bundled Plugins: Key Promoter X

Thanks so much for the support, I realize I'm using several products that aren't PHPStorm, and it's probably the combination of products in addition to whatever configuration I'm using.  I'll go ahead and use my "add to watches" work-around until a) I finish my current project, or b) the work-around becomes unbearable.

-James

0

I am having the exact same issue and not using Drupal.  Did you find a solution? Like you, I have been using PHPStorm debugger for years without issue and no settings changed. Its as if this issue just started overnight.  While I can see variables in the main code, ANY VARS created in functions are not recognized. Development was on track and came to a screeching halt.

0

Please sign in to leave a comment.