PHP 中的远程调试和内存分析

发布于 2024-08-16 11:49:42 字数 191 浏览 4 评论 0原文

两个问题

  1. 如何远程调试位于服务器上的PHP代码,目前我正在使用var_dump来检查变量的值?
  2. 我如何查看服务器上远程执行特定函数需要多少内存和多少时间,对此有什么好的分析器建议吗?

注意:我说的是远程位于服务器上的代码。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

英雄似剑 2024-08-23 11:49:42

正如其他人所说,Xdebug 是您最好的选择。我在这里顺便提一下几个分析器。如果您使用的是 Linux,那么 KCacheGrind 不会出错,而在 Windows 上,它会出现 WinCacheGrind 就是您要使用的。我不知道远程分析是一个选项,它转储到您需要访问的文件。不过,看来你已经习惯了。

Komodo 是一个相当不错的 IDE,支持 Xdebug(调试需要付费版本),虽然没有理由不只是安装 Eclipse 并选择 Zend PDT

我的建议是,使用 Python 进行编程并成为一名更快乐的开发人员(更多对开发人员友好的模块/工具):P

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

给妤﹃绝世温柔 2024-08-23 11:49:42

我认为 Xdebug 就是您正在寻找的。如果您不介意花钱,Zend IDE for Eclipse 附带了 Zend Debugger,而且它也运行得很好。

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.

御弟哥哥 2024-08-23 11:49:42

正如本德所说:XHProf [1]:http://pecl.php.net/package/xhprof [2]: http://mirror.facebook.net/facebook/xhprof/ doc.html 比 XDebug 轻得多,我更喜欢用它来获取有关实时站点的分析信息。 Facebook 使用它来分析他们的实时服务器。它具有很好的功能,例如聚合配置文件并在它们之间进行差异,这样您也可以看到代码中的回归。如果您需要逐步调试器,那么 XDebug 就是您的选择。请注意,默认情况下打开的实时站点上的 XDebug 会严重降低性能,并且站点生成的输出缓存研磨文件可能会很快填满磁盘。

我建议不要在实时站点上使用 XDebug,如果需要,请将其配置为通过触发器按需激活,如文档 http:// xdebug.org/docs/

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/

澉约 2024-08-23 11:49:42

配置您的服务器以允许 XDebug 远程调试并选择客户端,尽管设置可能有点复杂起来吧。我个人使用 emacs 的 Geben 作为 XDebug 的前端,但有很多选择。

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.

一个人的旅程 2024-08-23 11:49:42

只要您被允许在服务器上安装东西,Xdebug 就是进行调试和分析的方法。

如果您在共享服务器上,请忘记它(除非您是服务器管理员的好朋友)。你最好的机会似乎是 FirePHP - 仅用于调试。您可能还想看看dBug;它基本上是一个经过修饰的 var_dump,但您的眼睛会感激它。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文