9

UPDATE -- working on getting WAMP with phpDeveloper/Xdebug going. I still want NetBeans -- I just want to compare, see if I get some insights.


I am using NetBeans 6.9 with LAMP and Xdebug to work on PHP code. The Variables display works well, but lately it works less well. For example below, $authorized should be visible in the variables pane below the code and should expose its value. But it doesn't show, nor its value, and mousing over the code doesn't help. (The $this object is showing and it does go on and on, but $authorized isn't in there, and it wouldn't make sense if it were.)

This behavior is consistent. Maybe it's a function of the complexity of the code? Or rampant object usage? it seems to have started when I took up CodeIgniter.

Of course the variables are hidden when I need them most ... or so it seems to the poor human. What am I missing?

NetBeans debugger http://themanthursday.com/wiki/Debugger_Display.png

There's a better example below. When I'm stepping through this code, Variables displays only Superglobals and $this, just as in the picture. I can't see any values, even mere strings.

(Nagging thought: I bet the $CI SuperObject has something to do with all this ...)

class Product_documents {
  function getProductImage_all($id)
//Return an array of all documents for this product
{
  $imgPath = $this->_getProductImage_folder($id);
  $arrayPossibleFilenames = $this->_getProductImage_possible_files($id);
  foreach ($arrayPossibleFilenames as $imgFile) {
    $imgPathFull = $imgPath.$imgFile;

    $file_exists = get_file_info($imgPathFull);
    if ($file_exists) 
    {
    $arrayFilesPresent[] = $imgPathFull;
    }
  }
  return $arrayFilesPresent;        
}
}
SysDragon
  • 9,692
  • 15
  • 60
  • 89
Smandoli
  • 6,919
  • 3
  • 49
  • 83

6 Answers6

9

Right click on the variable pane. Select "Filters". You will find the secret.

  • Thanks Kamal. Ironically, I deleted NetBeans today, having moved back to phpDesigner Pro ... and having given up on CodeIgniter some time ago. I will continue to watch this post with interest, however. BTW, I concluded that CI's use of the singleton pattern was the key; I wonder if "the secret" you offered would validate that. – Smandoli Jun 08 '11 at 22:21
  • Thank you ! I thought that was another xdebug issue, this will save a lot of time to me – Benoit Feb 08 '12 at 09:34
  • Couldn't you just tell what this "secret" consists of instead? I'd like to know without having to install NetBeans on my iPad. – conny Dec 02 '14 at 09:53
  • This 'secret' lists types of variables that are shown in the debugger. Unitialized and null variables are not shown by default. Additionally, in php.ini under [xdebug], set xdebug.show_local_vars=1 if you want all the local variables - very important. – Cymbals Sep 16 '15 at 19:26
  • Thanks. This helped me with https://stackoverflow.com/q/54226662/470749 – Ryan Jan 17 '19 at 00:32
6

Came across this site that has a very nice link to an Xdebug page that walks one through the process of upgrading Xdebug by compiling a 'more latest' version:

http://icephoenix.us/php/xdebug-doesnt-show-local-variables-in-komodo-netbeans-or-eclipse-pdt/

Variables inside by objects/classes are showing up again! Yeah!

No watches, no 'this may make Xdebug freak out' messages - just good ol' variables that now fully expose the failure of my solution... (haha).

David

davidm777
  • 61
  • 3
2

I've seen stuff like this before in Netbeans. I expect it's just a bug involving Netbean's interaction with XDebug. One possible workaround that I've seen before is adding a "Watch" for the variable that you can't see. For your example, you could go to the "Watches" tab and type in $authorized. It should show up once it has been set.

Steven Oxley
  • 6,563
  • 6
  • 43
  • 55
  • Thanks, good idea. Using a watch didn't occur to me, only because in VBA they seem to be especially ineffective. I have to 'think outside the box' -- or to say it more rightly, I have to think inside a different box. – Smandoli Aug 18 '10 at 14:44
  • Yeah, unfortunately, this particular box might not always be the best environment to think in :P – Steven Oxley Aug 18 '10 at 15:01
  • Sorry to say, I been busy and have not tried this -- but I hope to try it tonight. As for the WAMP experiment, I still need to finish out with a working xDebug. (Sometimes I just I wish I could do my work in real-time. Ha ha.) – Smandoli Aug 20 '10 at 14:48
  • CONCLUSIONS: FIRST, Setting a watch works. Now in the screenshot above, $this and Superglobals are joined by a 3rd line, which is the watch. SECOND, I like Steven's 'just a bug' theory. THIRD, phpDesigner debugging seemed awkward (debugging for master page didn't stop at a breakpoint in a different page). So I couldn't get to a comparison test. I am sure with more effort, I could figure it out and make the comparison. IN CONCLUSION, NetBeans is workable (HOORAY) with this extra insight. – Smandoli Aug 20 '10 at 22:30
  • 1
    Bad after-conclusion: Using a watch worked on NetBeans on the WinXP machine. On home Ubuntu, setting watches to enabled causes Xdebug to completely boink. – Smandoli Aug 23 '10 at 00:40
  • @Smandoli sorry to hear that it didn't work on Ubuntu... Again, I might look into complaining to the Netbeans developers about this because there's obviously some buggy stuff going on there. Another thing to consider might be installing the newest version of Netbeans (as in a nightly build) and see if that still has the same problems. – Steven Oxley Aug 23 '10 at 18:33
  • Thanks Steven. I returned to phpDesigner and was interested to find it seems mildly compromised in exposing vars (says 'uninitialized' a lot, I feel sure that's a clue to the whole issue) -- BUT mouse-over works, so debugging is feasible. Very grateful for suggestions today, and will pursue as God grants me strength. – Smandoli Aug 23 '10 at 21:31
0

I think it comes down to the singleton pattern that is implemented in CodeIgniter as "Super Object". I never have restarted this project to test Kamal's idea. Shortly after he posted, I concluded the singleton was the reason (I did not try to guess whether Kamal has the solution or not). Thus my response to this post.

Community
  • 1
  • 1
Smandoli
  • 6,919
  • 3
  • 49
  • 83
0

(2015) In php.ini under [xdebug], set xdebug.show_local_vars=1 if you want all the local variables in debug mode.

Cymbals
  • 1,164
  • 1
  • 13
  • 26
  • It doesn't do what you think. From https://xdebug.org/docs/all_settings :: When this setting is set to something != 0 Xdebug's generated stack dumps in error situations will also show all variables in the top-most scope. Beware that this might generate a lot of information, and is therefore turned off by default. – Dakusan Feb 19 '17 at 20:42
-1

Try initializing $authorized to bool false.

I've seen Netbeans not show me variables initialized with a return value from a function without a doctype, but it's hit or miss enough to not be make a pattern out of.

Fanis Hatzidakis
  • 5,282
  • 1
  • 33
  • 36
  • I added this just above the breakpoint: $authorized = FALSE; No Change. Is that what you meant? Also, after posting I realized I can produce a more interesting example of unexposed variables ... I may work that up a bit later. – Smandoli Aug 14 '10 at 00:58
  • -1 because the suggestion didn't work, so the bounty ought to go somewhere else probably. But thank you Fanis for the suggestion. – Smandoli Aug 18 '10 at 14:46
  • No worries. Like I said, it's hit or miss for me. Something else I've noticed is it will occasionally fail to pick up variables in the global scope if the script being debugged has no functions. – Fanis Hatzidakis Sep 02 '10 at 09:34