Remote Debugging and Memory Profiling in PHP

假装没事ソ 提交于 2019-12-06 11:47:43

问题


Two Questions

  1. How can I debug PHP code remotely which is lying on the server, currently I am using var_dump's to check the value of variables ?
  2. How can I see how much memory and how much time particular function is taking to execute remotely which is lying on the server, any suggestion for good profiler for this ?

Note: I am talking about code which is lying remotely on the Server.


回答1:


Like others said, Xdebug is your best bet. I'll just chime in here and mention a couple profilers. If you're on Linux you can't go wrong with KCacheGrind and on Windows it appears WinCacheGrind is what you'd use. I was not aware of remote profiling being an option, it dumps to a file which you'd need to have access to. Although, it appears you are accustomed to that already.

Komodo is a pretty nice IDE with Xdebug support (debug requires paid version), although there is no reason to not just install Eclipse and pick up the Zend PDT.

My suggestion, program in Python and be a happier developer (more developer-friendly modules/tools) :P




回答2:


I think Xdebug is what you're looking for. If you don't mind spending the money, Zend IDE for Eclipse comes with Zend Debugger and it works quite well also.




回答3:


As bender said: XHProf [1]: http://pecl.php.net/package/xhprof [2]: http://mirror.facebook.net/facebook/xhprof/doc.html is much lighter then XDebug and I prefer it for taking profiling info about the live site. Facebook uses it for profiling their live servers. It has nice features like aggregating the profiles and making diffs between them so you can see the regression in your code as well. If you need step by step debugger then XDebug is your call. Just be aware that XDebug on live site turned on by default imposes important degradation of performance, and output cachegrind files that site generate could fill the disk very fast.

I suggest not using XDebug on live site and if needed configuring it to activate on demand through trigger as described in docs http://xdebug.org/docs/




回答4:


Configure your server to allow XDebug remote debugging and pick a client, although it can be a bit involved to set it up. I've personally used Geben for emacs as a front end for XDebug, but there are many choices.




回答5:


As far as you're allowed to install stuff on the server Xdebug is the way to go for both debugging and profiling.

If you are on a shared server forget about it (unless you are a good friend of the server admin). Your best chance seems to be FirePHP - for debugging only. You may want to take a look at dBug too; it's basically a prettied up var_dump, but your eyes will be grateful for it.



来源:https://stackoverflow.com/questions/1978603/remote-debugging-and-memory-profiling-in-php

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