Are there any PHP code visualization tools?

前端 未结 6 952
抹茶落季
抹茶落季 2020-12-24 07:48

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

相关标签:
6条回答
  • 2020-12-24 08:19

    Try JB Graph

    if you good in java script then try D3.js

    https://d3js.org/

    0 讨论(0)
  • 2020-12-24 08:23

    Maybe http://phpcallgraph.sourceforge.net/ for static analysis.

    It can output to various formats.

    0 讨论(0)
  • 2020-12-24 08:30
    • KCachegrind - With Xdebug you can profile the execution of your scripts, KCachegrind can generate some pretty awesome call graphs from this
    • nwire for Eclipse
    0 讨论(0)
  • 2020-12-24 08:31

    [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

    0 讨论(0)
  • 2020-12-24 08:33

    BOUML can make UML diagrams out of existing PHP code

    0 讨论(0)
  • 2020-12-24 08:37

    nWire is outdated, does not support latest PHP versions (namespaces). Community version of Visual Paradigm is free for non commercial projects, but fails on latest PHP versions too.

    phUML is very useful free tool It's not maintained anymore, but still works fine for PHP 5. Mac users shall install graphviz too.

    0 讨论(0)
提交回复
热议问题