9

Happens that I've ended up working on a big PHP program and I need a program (or easy to install script) which draws a flow control/call graph of a PHP application (ie; must work over multiple PHP files). Already saw stuff like Graphviz, not sure which one works for PHP?

Any suggestions?

Cheers!

ento
  • 5,801
  • 6
  • 51
  • 69
Christian
  • 27,509
  • 17
  • 111
  • 155

2 Answers2

9

I have never used any tool that can do that statically (i.e. from source files), but here's a way to get a callgraph when executing a script/application.


First, you need to install the Xdebug extension -- on a development/testing server (don't install it on a production server : it's quite bad for performances ^^ )

Then, you can use its profiling features to generate a .cachegrindout file corresponding to the execution of a page-load.


After that, you can load that .cachegrindout file with KCacheGrind (On linux -- I don't think there's a windows version) ; KCacheGrind can generate call-graphs from .cachegrindout files.

And here's an example of callgraph you can get :

KCacheGrind : Callgraph exported as an image
(source: pascal-martin.fr)

(Here's, it's been generated from a .cachegrindout file obtained while loading a page of Dotclear, a blogging software)

Glorfindel
  • 21,988
  • 13
  • 81
  • 109
Pascal MARTIN
  • 395,085
  • 80
  • 655
  • 663
2

Doxygen can do it statically. Just doxygen -d to create a config file, then edit it to create callgraphs.

Prof. Falken
  • 24,226
  • 19
  • 100
  • 173