是否有任何PHP代码可视化工具? [英] Are there any PHP code visualization tools?

查看:99
本文介绍了是否有任何PHP代码可视化工具?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

正在寻找可以分析php代码(即所有的wordpress或主题主题)并向我展示漂亮图片的软件(也许框图),以帮助我更快地了解事物在哪里以及什么与事物相连.

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.

理想情况下,该软件可以在Mac上运行,但我可以使用:Windows,Linux,基于Web等.

Ideally, this software would run on a Mac, but I'll take anything: Windows, Linux, web-based, etc.

推荐答案

[更新:此答案不处理名称空间,因此基本上已过时.如果有人发现DOT方法有趣,我将其保留在这里.]

这是在PHP中绘制类继承的一种简单方法.

Here's a simple way to graph class inheritance in PHP.

使用Grep定义类,然后将grep输出转换为DOT语法.注意:根据您的情况,此过程将需要反复试验.单独运行grep,并对其进行调整以显示正确的类定义行,然后再将其放入脚本!

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!

此脚本用于标准* nix(我使用Ubuntu)上的PHP,安装了graphviz,并使用grep -v排除了一些不感兴趣的目录,因为我正在查看CakePHP代码库.在这种情况下,Fdp的效果比sddp,dot,circo或neato更好.

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.

创建generateClassHierarchy.sh

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"; 

然后:

cd /var/www/my_app/                     # or wherever
bash ~/shell/generateClassHierarchy.sh  # or wherever
eog code.fdp.png 

将eog替换为您喜欢的图像查看器.我已经在Zend Framework上进行了测试,并生成了22 MB的PNG图.仅在Zend_Db上运行即可显示此信息(示例在我的网站上):

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-heritanceance-diagrams-graphviz

这篇关于是否有任何PHP代码可视化工具?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆