tags:

views:

200

answers:

3

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

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;        
}
}
A: 

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
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
-1 because the suggestion didn't work, so the bounty ought to go somewhere else probably. But thank you Fanis for the suggestion.
Smandoli
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
A: 

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
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
Yeah, unfortunately, this particular box might not always be the best environment to think in :P
Steven Oxley
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
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
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
@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
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
A: 

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