PHP Classes

Code Graph: Generate call graphs of PHP code with GraphViz

Recommend this page to a friend!
  Info   Screenshots Screenshots   View files View files (6)   DownloadInstall with Composer Download .zip   Reputation   Support forum (5)   Blog    
Ratings Unique User Downloads Download Rankings
StarStarStarStar 66%Total: 1,144 This week: 1All time: 3,298 This week: 571Up
Version License PHP version Categories
code-graph 0.1BSD License4Tools, Language
Description 

Author

This packages can be used to generate call graphs of PHP code with GraphViz.

There is one class that can generate diagrams in the GraphViz DOT format from a list of called or uncalled functions.

Additional functions can parse given PHP scripts to extract the list of functions in the code to generate the call tree graph.

Innovation Award
PHP Programming Innovation award nominee
January 2011
Number 3


Prize: One downloadable e-book of choice by Manning
Sometimes it is useful to see which code is being used or not used in your applications. One way to see that information is to generate visual code call graphs.

This package implements a solution to generate call graphs from PHP code in GraphViz format. The generated GraphViz files can be viewed or rendered in many graphical formats.

Manuel Lemos
Picture of Colin McKinnon
  Performance   Level  
Name: Colin McKinnon <contact>
Classes: 5 packages by
Country: United Kingdom
Age: ???
All time rank: 144867 in United Kingdom
Week rank: 420 Up10 in United Kingdom Up
Innovation award
Innovation award
Nominee: 4x

Details

Codegraph requires the Graphviz package (which does the *really* clever stuff). Codegraph ppackages are available from various places, or you can download the source at: http://www.graphviz.org/ This is the second release version which has a much cleaner API. To see what it does checkout the key.jpeg and self.jpeg files (the latter is the result of running the code on itself). The example scripts expects a writable directory called 'graphs' in the same dir. The dotwriter.inc.php defines 2 classes and some supporting functions. It should come with this readme.txt file and 3 example scripts. * example1.php provides a user to upload a PHP src file and returns the resulting jpeg image * example2.php This was front end which shiped with the first verion - and allows you to try out the different options for the graph generator * example3.php This script defines a callback handler which adds URLs to the nodes rendered in the image - maaking them clickable. It is configured to geerate links to PHPXREF documentation. It has been written for Unix/Linux systems but would not require l ot of changes to support MSWindows: I believe the only change necessary is to specify the location of the graphViz dot interpreter. This is currently hard-coded as /usr/bin/dot. However the value can be overridden at run time between instantiating the dotrunner class and generating the output file, e.g. $c = new dotrunner(); $c->graphVizBin='/windows/cygwin/usr/bin/dot.exe'; $c->outputFileName=tempnam('graphs/','graph'); $c->genGraph(.... To see what it does checkout the key.jpeg and self.jpeg files (the latter is the result of running the code on itself). The script expects a writable directory called 'graphs' in the same dir. Note the 'cleanUp()' method defined in the class deletes the graphViz input file but not the output file(s). You should plan to make some provision for these in your own code.

Screenshots  
  • key.jpg
  • self
  Files folder image Files  
File Role Description
Accessible without login Plain text file dotwriter.inc.php Class includeable parser/generator
Accessible without login Plain text file example1.php Example Usage example
Accessible without login Plain text file example2.php Example Usage example
Accessible without login Plain text file example3.php Example Usage example
Accessible without login Plain text file parse_gen.php Example source code and front end
Accessible without login Plain text file README Doc. instructions

 Version Control Unique User Downloads Download Rankings  
 0%
Total:1,144
This week:1
All time:3,298
This week:571Up
User Ratings User Comments (2)
 All time
Utility:87%StarStarStarStarStar
Consistency:87%StarStarStarStarStar
Documentation:68%StarStarStarStar
Examples:68%StarStarStarStar
Tests:-
Videos:-
Overall:66%StarStarStarStar
Rank:548