PHP call graph utility? [closed]

落花浮王杯 提交于 2019-11-28 03:59:38
Bjarke Freund-Hansen

I would definitely try Doxygen. It has support for PHP, and the call graphs and caller graphs it creates have been very useful in exploring "foreign code" for me previously.

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.

You might want to take a look at the Xdebug extension : it brings profiling to PHP, and and generate callgrind-like files, that can be read with KCacheGrind on Linux.

And this one is able to generate some kind of callgraphs.


It can also be integrated with PHPUNit, to generate code-coverage when running unit-tests
Some time ago, PHPUnit was able to generate some callgraphs with graphviz ; I don't find that option anymore, though :-(


EDIT : it's the first time I hear about it, but there is a project called phpCallGraph that might be able to help you, too... and it seems there is work going on, if I look at it's changelog

troelskn

As noted already, Doxygen can generate call graphs.

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.

There is also the bytekit extension, 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.

symcbean

This is an old topic - but in case anyone finds it useful....

  • kKCachegrind will produce callgraphs shown the actual execution threads.

  • PHPCallGraph is a fairly simple around graphviz which perfroms static analysis

  • There's also my own effort which 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.

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!