【问题标题】:Xdebug profiler is not working?Xdebug 探查器不工作?
【发布时间】:2011-12-25 23:29:57
【问题描述】:

我使用 XAMPP 并对其进行了配置,以便为我在本地创建的每个项目提供虚拟主机。

在我的 php.ini 中,我启用了 xdebug,并且我的脚本工作正常。我的意思是任何时候有警告、通知、错误,都是由xdebug报告的。

现在我想启用 Xdebug 分析器,并且我对我的 php.ini 进行了以下更改,以允许 Xdebug 分析器生成日志文件:

; xdebug.profiler_enable
; Type: integer, Default value: 0
; Enables Xdebugs profiler which creates files in the profile output directory. Those files can be
; read by KCacheGrind to visualize your data. This setting can not be set in your script with ini_set
; ().
xdebug.profiler_enable = 1

; xdebug.profiler_output_dir
; Type: string, Default value: /tmp
; The directory where the profiler output will be written to, make sure that the user who the PHP
; will be running as has write permissions to that directory. This setting can not be set in your
; script with ini_set().
xdebug.profiler_output_dir ="D:\Web Development Projects\Profile"

我重新启动了我的 Apache,但是当我运行我的脚本时,文件夹 Profile 中没有生成任何文件。

我还有什么需要做的吗?

为了启用 Profiler,我已阅读:http://xdebug.org/docs/profiler


经过一番研究,我在我的服务器中安装的 WordPress 中的 index.php 末尾添加了该代码:

echo xdebug_get_profiler_filename();

在我运行 WordPress 之后,在页脚处我得到了结果:

D:/Web Development Projects/Profile/xdebug_profile._::1320916508_018294

但是当我去文件夹时

D:/Web Development Projects/Profile/

文件没有出现在那里?有什么想法吗?

【问题讨论】:

  • 我忘了写操作系统是Windows

标签: php windows xdebug


【解决方案1】:

我在使用 Fedora Linux v.32 时遇到了类似的问题。 设置是正确的,但是我在 /tmp 中找不到探查器转储。

这是因为 RedHat Linux 安全功能:PrivateTmp,也在 Fedora 16 和更新版本中引入。

这意味着使用此标志运行的进程将看到与用户和其他守护程序看到或可以访问的用户不同且唯一的 /tmp。

就我而言,唯一目录是:

/tmp/systemd-private-05139aa229424bc389df850760710371-php-fpm.service-vLI9Th

【讨论】:

    【解决方案2】:

    如果您在 Linux 上,请检查您是否不在 PrivateTmp 中,否则所有内容都写入 /tmp 检查这个解释PrivateTmp的林

    【讨论】:

      【解决方案3】:

      问题解决了!

      由于日志文件名而产生的问题。

      我刚刚改成:

      xdebug.profiler_output_name = "callgrind.out.%t-%s"
      

      并且工作正常!

      【讨论】:

      • 请注意,如果您使用的是 WinCacheGrind 之类的只能识别一种文件类型的软件,则名称应为 cachegrind 而不是 callgrind
      • @KodeFor.me 你能写下 php.ini 文件的所有配置吗?我正在尝试但没有用。
      • @MuradShukurlu 这是四年前的项目,不幸的是不再存在,最重要的是,我什至不记得我设置了哪些选项。有用的资源在这里:xdebug.profiler_output_namestring xdebug.trace_output_name
      • @KodeFor.Me 谢谢!,我在查看更新日志后解决了问题。
      【解决方案4】:

      首先,您需要确保运行您的网络服务器的用户实际上对您指定的目录具有写入权限,并且该用户需要存在。 Xdebug 也可能不喜欢路径中的空格,虽然这应该可以正常工作,但我会尝试设置:

      xdebug.profiler_output_dir = "D:/Web Development Projects/Profiler"
      

      因为 \ + 字符可能是一个转义序列。

      【讨论】:

      • 让我试试。我会在一分钟内回答这里
      • 我只是做了那个改变,还是什么都没有。
      • 这个目录也需要可写
      • 对我来说这是写权限,简单的事情,但我们发现自己正在寻找复杂的解决方案。谢谢。 :)
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-11-28
      • 2022-11-12
      • 2015-11-30
      • 2018-11-01
      相关资源
      最近更新 更多