How to trace code execution in PHP?

半腔热情 提交于 2019-11-30 13:00:21

问题


I would like to see a log of THE WHOLE code execution of PHP script(s). Something like this: http://en.wikibooks.org/wiki/Ruby_Programming/Standard_Library/Tracer (for lack of better example; no flame please).

Is there some way how to obtain the log in PHP?

Note: I know I can use a debugger but that's not the same.


回答1:


Xdebug is definitely what you want, but with something like callgrind from the valgrind suite as well.

Zend blog post here should give you some pointers: http://devzone.zend.com/1139/profiling-php-applications-with-xdebug/




回答2:


phptrace is an awesome tool to trace php code executions




回答3:


In any function you can see the whole backtrace by using debug_backtrace(...)

Or you can use Xdebug profiler to profile your PHP scripts.




回答4:


Have a look at Kint.

It's var_dump() and debug_backtrace() on steroids. Easy to use, but powerful and customizable. An essential addition to your development toolbox.

it also has platform specific extensions here




回答5:


You can use a PHP extension called : XHProf, developed by Facebook.

It is capable of reporting function-level call counts and inclusive and exclusive wall time, CPU time and memory usage.

https://github.com/facebook/xhprof



来源:https://stackoverflow.com/questions/14341757/how-to-trace-code-execution-in-php

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