Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><strong>[UPDATE: This answer does not handle namespaces, so is basically obsolete. I'll leave it here in case anyone finds the DOT approach interesting.]</strong></p> <p>Here's a simple way to graph class inheritance in PHP. </p> <p>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! </p> <p>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. </p> <p>Create generateClassHierarchy.sh </p> <pre><code>#!/bin/bash echo 'digraph code {' &gt; code.dot; grep -r "^class " * | grep -v "^app/vendors" | grep -v "^cake/" | grep -v "Binary file" | sed 's/.*://' | sed 's/class / /' | sed 's/ extends / -&gt; /' | sed 's/ implements .*//' | sed 's/ \?{.*$//' | sort &gt;&gt; code.dot echo '}' &gt;&gt; code.dot; fdp -Tpng -ocode.fdp.png code.dot 2&gt; /dev/null # Ignore syntax error echo "OK"; </code></pre> <p>Then just:</p> <pre><code>cd /var/www/my_app/ # or wherever bash ~/shell/generateClassHierarchy.sh # or wherever eog code.fdp.png </code></pre> <p>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): </p> <p><a href="http://chapman.id.au/generate-php-class-inheritance-diagrams-in-graphviz" rel="nofollow">http://chapman.id.au/generate-php-class-inheritance-diagrams-in-graphviz</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload