php PHP调用图实用程序?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1235513/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
PHP call graph utility?
提问by glomad
I'm looking for a utility similar to gprof that will generate a call graphfor PHP code. I'd prefer something that can produce graphical output, or at least text output that can be interpreted by GraphViz or similar, but I'll settle for plain text output.
我正在寻找类似于 gprof 的实用程序,它将为 PHP 代码生成调用图。我更喜欢可以产生图形输出的东西,或者至少可以由 GraphViz 或类似工具解释的文本输出,但我会满足于纯文本输出。
Does anyone know of any tool that can do this?
有谁知道任何可以做到这一点的工具?
回答by Bjarke Freund-Hansen
回答by Pascal MARTIN
Not sure there exists anything that can analyse source-code written in PHP to generate that... But there is a possiblity, when you are running the code.
不确定是否存在任何可以分析用 PHP 编写的源代码来生成它的东西……但是当您运行代码时,有一种可能性。
You might want to take a look at the Xdebugextension : it brings profilingto PHP, and and generate callgrind-like files, that can be read with KCacheGrindon Linux.
你可能想看看Xdebug扩展:它为PHP带来了分析,并生成了类似 callgrind 的文件,可以在 Linux 上用KCacheGrind 读取。
And this one is able to generate some kind of callgraphs.
这个能够生成某种调用图。
It can also be integrated with PHPUNit, to generate code-coveragewhen running unit-tests
Some time ago, PHPUnit was able to generate some callgraphs with graphviz ; I don't find that option anymore, though :-(
它还可以与 PHPUNit 集成,以在运行单元测试时
生成代码覆盖率
前段时间,PHPUnit 能够使用 graphviz 生成一些调用图;不过,我再也找不到那个选项了:-(
EDIT : it's the first time I hear about it, but there is a project called phpCallGraphthat might be able to help you, too... and it seems there is work going on, if I look at it's changelog
编辑:这是我第一次听说它,但有一个名为phpCallGraph的项目也可以帮助你......而且似乎有工作正在进行,如果我看看它的更新日志
回答by troelskn
As noted already, Doxygen can generate call graphs.
如前所述,Doxygen 可以生成调用图。
Xdebug can generate function traces. These differ from doxygen's graphs in that they are generated from runtime code, whereas doxygen is generated statically. I don't know of any tools that can turn the function traces into a visual representation, although it shouldn't be that hard to do.
Xdebug 可以生成函数跟踪。它们与 doxygen 的图形不同,它们是从运行时代码生成的,而 doxygen 是静态生成的。我不知道有什么工具可以将函数轨迹转化为可视化表示,尽管这样做应该不难。
There is also the bytekitextension, which primary function is to show the bytecode that php source code will generate. It can show this in a graph, that is essentially a callgraph.
还有bytekit扩展,它的主要功能是显示 php 源代码将生成的字节码。它可以在图表中显示这一点,这本质上是一个调用图。
回答by symcbean
This is an old topic - but in case anyone finds it useful....
这是一个古老的话题 - 但万一有人觉得它有用......
kKCachegrind will produce callgraphs shown the actual execution threads.
PHPCallGraphis a fairly simple around graphviz which perfroms static analysis
There's also my own effortwhich is similar to PHPCallGraph but adds information about loops/conditional structures and provides a method for adding callbacks to nodes. Some example scripts are bundled with the toolkit - but you can also embed it in your own scripts.
kKCachegrind 将生成显示实际执行线程的调用图。
PHPCallGraph是一个相当简单的图形可视化工具,它执行静态分析
还有我自己的努力,它类似于 PHPCallGraph,但添加了有关循环/条件结构的信息,并提供了一种向节点添加回调的方法。一些示例脚本与工具包捆绑在一起 - 但您也可以将其嵌入到您自己的脚本中。
回答by zvikico
If you need something interactive, check out the new nWire for PHP. It is an Eclipse plugin which works with either PDT 2.1 and Zend Studio 7.0.
如果您需要交互式的东西,请查看新的nWire for PHP。它是一个 Eclipse 插件,适用于 PDT 2.1 和 Zend Studio 7.0。


