Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Eclipse debugger (PHP) - how to see super globals and class properties?

Is it possible to see PHP super globals like $_SESSION and $_POST in the debugger variables perspective?

Also, in the following example...

class myclass {
    public myvar = 'value';
    ...
}

... if I'm debugging the class I'd like to be able to see $this->myvar in the debugger

like image 267
Owen Avatar asked Nov 05 '22 15:11

Owen


2 Answers

It appears as though the availability of superglobals changed significantly in ZS8. From this post in Zend Forums:

During development of Zend Studio 7 the decision was made to restrict the variables list displayed in the Variables view to the current scope (e.g. current function scope). We are convinced that this approach provides better usability and performance of debugging. BTW, this is a standard approach for many IDE products.

I can't say this makes much sense to me (actually it's a pain in the neck) and if it is indeed becoming standard in many IDEs that seems less like justification for the ZS8 change and more like a widespread bad idea. But I'll quit griping.

The post seems to insinuate that you can view the superglobals by switching the stack you are viewing in the debugger (and they gave this rather unhelpful link). I have not had success with this.

For the time being, the only apparent way to view superglobals is by opening the expressions view (Window > Show View > Expressions) and typing in the variable you wish to see.

like image 115
doub1ejack Avatar answered Nov 09 '22 07:11

doub1ejack


You can add a watch expression for that variable in the Expression View. If you don't already have the Expression View in your perspective you can do so from the top menu

Window -> Show View -> Expressions

then click the + (plus sign) and enter $_POST. It can be any expression that would evaluate in the scope you're in. So, $this->myvar would work.

like image 20
Thanh Nguyen Avatar answered Nov 09 '22 07:11

Thanh Nguyen