Reputation: 36393
PHP provides some impressive introspection facilities: get_defined_vars
, get_defined_functions
, get_defined_constants
, debug_backtrace
, and others. Essentially, these provide views of the entire program state: the stack and the heap. I wonder how complete a view of the program state one can get using these facilities.
The heap and all defined variables in scope can be modelled as a labelled directed graph. So is it possible, for example, to write something that will give me a Graphviz/DOT depiction of this? I'm imagining something similar to the diagrams in this article about 'How PHP manages variables', or to the diagrams in the PHP manual page on garbage collection.
Upvotes: 9
Views: 837
Reputation: 1458
get_defined_vars
get_defined_functions
get_defined_constants
Is there a way to get user-defined php functions, variables, constants from a php file? Following functions are not the best way to do so because they get all decalred functions/vars/constants (with hundreds of php's built-in constants and internal php functions
Upvotes: 0
Reputation: 1458
If you generate a profile you can put the results into kcachegrind or wincachegrind to get a map view of memory allocation, time spent in each function and other things.
https://www.youtube.com/watch?v=YHKFdfbcP8U
Upvotes: 1
Reputation: 123
Checkout xdebug plus the xdebug chrome extension. https://chrome.google.com/webstore/detail/xdebug-helper/eadndfjplgieldjbigjakmdgkmoaaaoc?hl=en
The extension can be used to enable profiling / debugging for php. You can link it with eclipse or any other ide that supports xdebug for debugging.
If you generate a profile you can put the results into kcachegrind or wincachegrind to get a map view of memory allocation, time spent in each function and other things.
https://www.youtube.com/watch?v=YHKFdfbcP8U
Upvotes: 1
Reputation: 3
I don't know if there are any existing tools for but you should definitely check out the xdebug profiler http://xdebug.org/docs/profiler coupled with kcachegrind. It will give you a visualization of the entire stack: every function that was called, how many times it was called and how long it/they took.
Upvotes: 0