Looking for software that will analyze php code (i.e. all of wordpress or the thematic theme) and show me pretty pictures (perhaps a block diagram) of all the connections to help me more quickly get an understanding of where things are and what's connected to what.
Ideally, this software would run on a Mac, but I'll take anything: Windows, Linux, web-based, etc.
PHP runs on various platforms (Windows, Linux, Unix, Mac OS X, etc.) PHP is compatible with almost all servers used today (Apache, IIS, etc.)
You don't need to write any code to easily create interactive data visualization. When it comes to presenting data, spreadsheets and reports full of text aren't enough to explain what we found. This is when we need data visualization to present the data in a way that helps everyone grasp difficult concepts.
[UPDATE: This answer does not handle namespaces, so is basically obsolete. I'll leave it here in case anyone finds the DOT approach interesting.]
Here's a simple way to graph class inheritance in PHP.
Grep for class definitions and then transform the grep output to DOT syntax. NOTE: This process WILL require trial and error in your situation. Run the grep separately, and tweak it to show the right class definition lines before putting it in the script!
This script was for PHP on standard *nix (I used Ubuntu), with graphviz installed, and using grep -v to exclude some directories that were of no interest because I was looking at a CakePHP codebase. Fdp worked better than sfdp, dot, circo or neato in this situation.
Create generateClassHierarchy.sh
#!/bin/bash
echo 'digraph code {' > code.dot;
grep -r "^class " * | grep -v "^app/vendors" | grep -v "^cake/" | grep -v "Binary file" | sed 's/.*://' | sed 's/class / /' | sed 's/ extends / -> /' | sed 's/ implements .*//' | sed 's/ \?{.*$//' | sort >> code.dot
echo '}' >> code.dot;
fdp -Tpng -ocode.fdp.png code.dot 2> /dev/null # Ignore syntax error
echo "OK";
Then just:
cd /var/www/my_app/ # or wherever
bash ~/shell/generateClassHierarchy.sh # or wherever
eog code.fdp.png
Replace eog with your preferred image viewer. I have run this on Zend Framework as a test, and produced a 22 megabyte PNG graph. Running it on just Zend_Db shows you this (example is on my site):
http://chapman.id.au/generate-php-class-inheritance-diagrams-in-graphviz
Maybe http://phpcallgraph.sourceforge.net/ for static analysis.
It can output to various formats.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With