简体   繁体   English

PHP调试器不会在断点处停止:Eclipse和Xdebug

[英]PHP Debugger will not stop at breakpoints: Eclipse & Xdebug


Client Side Tools: ( No Apache, No PHP ) 客户端工具:(没有Apache,没有PHP)


Eclipse for PHP Developers 用于PHP开发人员的Eclipse

Version: Oxygen.2 Release (4.7.2) 版本:Oxygen.2发布(4.7.2)

Build id: 20171218-0600 Build id:20171218-0600

Redhat Enterprise Linux 6.9 Redhat Enterprise Linux 6.9

java version "1.8.0_101" java版“1.8.0_101”

Java(TM) SE Runtime Environment (build 1.8.0_101-b13) Java(TM)SE运行时环境(版本1.8.0_101-b13)

Java HotSpot(TM) 64-Bit Server VM (build 25.101-b13, mixed mode) Java HotSpot(TM)64位服务器VM(内置25.101-b13,混合模式)


Remote Server Where The PHP web app is: 远程服务器PHP Web应用程序的位置是:


PHP 5.6.5 PHP 5.6.5

Zend Engine v2.6.0 , Copyright (c) 1998-2014 Zend Technologies Zend Engine v2.6.0 ,版权所有(c)1998-2014 Zend Technologies

with Zend OPcache v7.0.4-dev, Copyright (c) 1999-2014, by Zend Technologies Zend技术公司的Zend OPcache v7.0.4-dev,版权所有(c)1999-2014

with Xdebug v2.2.7, Copyright (c) 2002-2015, by Derick Rethans Derde Rethans的Xdebug v2.2.7,版权所有(c)2002-2015


I've found previous posts on this topic. 我在此主题上发现了以前的帖子。 I didn't understand all of the things to try. 我不明白所有要尝试的事情。 I tried what I could understand, but did not have any luck. 我尝试了我能理解的东西,但没有任何运气。 Mostly just using xdebug_break(); 主要是使用xdebug_break(); ( again, no luck ) (再次,没有运气)


I am using Eclipse and Xdebug to debug a remote PHP web site. 我正在使用Eclipse和Xdebug来调试远程PHP网站。 My problem is I can not get the debugger to stop on the breakpoints I set. 我的问题是我无法让调试器停在我设置的断点上。

I am doing remote PHP development with Eclipse and a "Synchronized PHP Project. Nothing except Eclipse is running on my computer. 我正在使用Eclipse和“同步PHP项目”进行远程PHP开发。除了Eclipse之外没有任何东西在我的计算机上运行。

I am using the Xdebug debugger on the remote server through Eclipse. 我通过Eclipse在远程服务器上使用Xdebug调试器。

When I use the debugger it will go to the index.php. 当我使用调试器时,它将转到index.php。 I can step through for a while and see the value of variables. 我可以走一段时间,看看变量的价值。

The problem is that Xdebug will not stop at any of the breakpoints I set. 问题是Xdebug不会在我设置的任何断点处停止。

I am including my Xdebug settings 我包括我的Xdebug设置

Any clues as to how to find and fix the problem would be welcome 任何有关如何找到并解决问题的线索都会受到欢迎

Xdebug Settings: Xdebug设置:

xdebug support,enabled
Version,2.2.7

DBGp - Common DeBuGger Protocol,$Revision: 1.145 $

Directive,Local Value,Master Value

xdebug.auto_trace,Off,Off
xdebug.cli_color,0,0
xdebug.collect_assignments,Off,Off

xdebug.collect_includes,On,On

xdebug.collect_params,0,0
xdebug.collect_return,Off,Off
xdebug.collect_vars,Off,Off

xdebug.coverage_enable,On,On
xdebug.default_enable,On,On

xdebug.dump.COOKIE,no value,no value
xdebug.dump.ENV,no value,no value
xdebug.dump.FILES,no value,no value
xdebug.dump.GET,no value,no value
xdebug.dump.POST,no value,no value
xdebug.dump.REQUEST,no value,no value
xdebug.dump.SERVER,no value,no value
xdebug.dump.SESSION,no value,no value

xdebug.dump_globals,On,On
xdebug.dump_once,On,On

xdebug.dump_undefined,Off,Off

xdebug.extended_info,On,On

xdebug.file_link_format,no value,no value

xdebug.max_nesting_level,100,100
xdebug.overload_var_dump,On,On

xdebug.profiler_aggregate,Off,Off
xdebug.profiler_append,Off,Off
xdebug.profiler_enable,Off,Off

xdebug.profiler_enable_trigger,On,On
xdebug.profiler_output_dir,/tmp,/tmp
xdebug.profiler_output_name,cachegrind.out.%t.%s,cachegrind.out.%t.%s

xdebug.remote_autostart,Off,Off

xdebug.remote_connect_back,On,On
xdebug.remote_cookie_expire_time,3600,3600
xdebug.remote_enable,On,On
xdebug.remote_handler,dbgp,dbgp
xdebug.remote_host,127.0.0.1,127.0.0.1
xdebug.remote_log,/var/log/xdebug/xdebug.log,/var/log/xdebug/xdebug.log
xdebug.remote_mode,req,req
xdebug.remote_port,9000,9000

xdebug.scream,Off,Off
xdebug.show_exception_trace,Off,Off
xdebug.show_local_vars,Off,Off
xdebug.show_mem_delta,Off,Off
xdebug.trace_enable_trigger,Off,Off

xdebug.trace_format,0,0
xdebug.trace_options,0,0
xdebug.trace_output_dir,/tmp,/tmp
xdebug.trace_output_name,trace.%c,trace.%c
xdebug.var_display_max_children,128,128
xdebug.var_display_max_data,512,512
xdebug.var_display_max_depth,3,3

Edit 编辑

I created an album of screen shots. 我创建了一个屏幕截图专辑。

First one is an error message from Eclipse that happens when I leave it on all night. 第一个是来自Eclipse的错误消息,当我整夜离开它时发生。

The rest of the screen shots are pieces, in order ( top->down ) of my phpinfo output. 屏幕截图的其余部分是我的phpinfo输出的顺序(顶部>向下)。

https://imgur.com/a/9DKev https://imgur.com/a/9DKev

There is no Zend section in my phpinfo() output, though there are these vars 我的phpinfo()输出中没有Zend部分,尽管有这些变量

report_zend_debug = on
zend.detect_unicode On
zend.enable_gc  On
zend.multibyte  Off 
zend.script_encoding = no value

From your description, it seems that: 根据您的描述,似乎:

  • the debug connection to your remote server is working 与远程服务器的调试连接正常
  • breaking points work on the index.php, but not anywhere else 破坏点在index.php上工作,但不在其他任何地方

My assumption is that the file mapping between local and server code is not working, more precisely eclipse cannot map your files to the server ones. 我的假设是本地代码和服务器代码之间的文件映射不起作用,更确切地说,eclipse无法将您的文件映射到服务器代码。

To solve this, you have to set the path mapping setting inside your eclipse project `s run/debug settings . 要解决这个问题,您必须在eclipse项目的运行/调试设置中设置 路径映射 设置

Go to: 去:

  1. Project -> Properties from the menu 项目 - >菜单中的属性
  2. Select Run/Debug Settings 选择“运行/调试设置”
  3. Edit your launch configuration settings 编辑启动配置设置
  4. On the tab Server, section PHP server , select configure 在选项卡Server,部分PHP服务器上 ,选择configure
  5. "PHP Server" window is opened, select path mapping tab 打开“PHP Server”窗口,选择路径映射选项卡
  6. Set Path on server to your project `s path on server and set Local path to well this is self explanatory. 服务器上的Path设置为服务器上项目的路径,并将Local path设置为well,这是不言自明的。

在此输入图像描述

If you follow below steps I think it should work 如果你按照以下步骤我认为它应该工作

Latest XDebug version 最新的XDebug版本

Your XDebug version is from 2015 as per this https://xdebug.org/ . 根据此https://xdebug.org/,您的XDebug版本是2015年。 So you should upgrade to the latest version 所以你应该升级到最新版本

Setting up XDebug configuration 设置XDebug配置

Setup a 99-xdebug.ini in your /usr/local/etc/php/conf.d/ or /etc/php/conf.d or /etc/php/5.6/cli/conf.d depending on which exists on your system /usr/local/etc/php/conf.d//etc/php/conf.d/etc/php/5.6/cli/conf.d设置99-xdebug.ini ,具体取决于你的系统

xdebug.remote_enable=1
xdebug.remote_host=127.0.0.1
xdebug.remote_handler=dbgp
xdebug.remote_port=9000
xdebug.remote_autostart=1
xdebug.remote_log=/tmp/xdebug.log

Create a SSH Debug Tunnel 创建SSH调试隧道

The machine from where you want to debug, you need to start a SSH tunnel using 要从中调试的机器,需要使用启动SSH隧道

ssh -R 127.0.0.1:9000:127.0.0.1:9000 -p 22 <user>@<phpserver>

Configure Remote Path mapping in Eclipse 在Eclipse中配置远程路径映射

Configure eclipse for the debugging on port 9000 and remote paths and now it should work 在端口9000和远程路径上配置eclipse以进行调试,现在应该可以正常工作

Try to disable things like: opcache, zend optimizer, and so on, all extensions what work with interpretation php code. 尝试禁用以下内容:opcache,zend optimizer等,所有扩展与解释php代码一起使用。 If you luck and it start working, make xdebug.so loads last, after all another modules, so you can re enable them again. 如果运气好并且它开始工作,请在所有其他模块之后最后加载xdebug.so,以便重新启用它们。 Place xdebug.so in folder where all other php .so resides, and load it in last line of php ini, with full path to xdebug.so 将xdebug.so放在所有其他php .so所在的文件夹中,并将其加载到php ini的最后一行,并带有xdebug.so的完整路径

If you just place it in last line php.ini, then some incompatible module can load up after, with config from /etc/php/5.6/apache2/conf.d/*. 如果你只是将它放在最后一行php.ini中,那么一些不兼容的模块可以在之后加载,使用/etc/php/5.6/apache2/conf.d/*中的config。 So just move configs somewhere for a while. 所以只需将配置移动一段时间。

At the link, in bottom of post, I do disable( but do not remove by apt ) opchache module totally, and place its in php.ini, 1 line before debugger. 在链接,在帖子的底部,我完全禁用( 但不要通过apt删除 )opchache模块,并在调试器之前将其放在php.ini,1行。

Check order how extensions loaded in phpinfo() output, to the left of zend logo, as I remember. 正如我记得的那样,检查在zend徽标左侧的phpinfo()输出中加载扩展的顺序。 Debugger must be last line in that block of output. 调试器必须是该输出块的最后一行。 Post you phpinfo(); 发布你的phpinfo(); output. 输出。

Another way, what I walk my own: (and I recommend it) 另一种方式,我走自己的路:(我推荐它)

If you have root access to remote server, try Zend Debugger. 如果您具有远程服务器的root访问权限,请尝试Zend Debugger。 Its bundled with Zend Studio(not free), but there are separate downloads of debugger for some php versions, 5.6 is the latest version it available for. 它与Zend Studio捆绑(不是免费的), 但是对于某些php版本有单独的调试器下载,5.6是它可用的最新版本。 They don`t publish it for php7, anyway I don`t known if it possible to copy it from trial Zend studio. 他们不会发布它为php7,无论如何我不知道是否有可能从试用Zend工作室复制它。 If it removed, unable to download, I can send it to you. 如果删除,无法下载,我可以发送给您。

Zend debugger are more native for php now, And Zend team involved in Eclipse PDT development(but they realized most tasteful features in paid version) Zend调试器现在更适用于php,Zend团队参与Eclipse PDT开发(但他们在付费版本中实现了最有品位的功能)

I have similar environment to yours, also have problems with XDebug, then decided to remove it and try Zend debugger. 我有类似的环境,也有XDebug的问题,然后决定删除它并尝试Zend调试器。 There are my question and answer on askubuntu, about installing it and fix problems: https://askubuntu.com/questions/1002252/installing-configuring-zend-debugger-for-eclipse-pdt 在askubuntu上有关于安装和修复问题的问题和答案: https ://askubuntu.com/questions/1002252/installing-configuring-zend-debugger-for-eclipse-pdt

In few words solution was: 简言之,解决方案是:

Comment out it in config: (cli version seems to be symlink as also disabled) 在config中注释掉它(cli版本似乎也是symlink也被禁用)

lenya@JabbaDesktop:~$ sudo nano /etc/php/5.6/apache2/conf.d/10-opcache.ini

; configuration for php opcache module
; priority=10
; zend_extension=opcache.so

At bottom of /etc/php/5.6/apache2/php.ini: 在/etc/php/5.6/apache2/php.ini的底部:

[Zend]
zend_extension="/usr/lib/php/20131226/opcache.so"
zend_extension="/usr/lib/php/20131226/ZendDebugger.so"
zend_debugger.allow_hosts=127.0.0.0/8,192.168.0.0/16
zend_debugger.expose_remotely=1
zend_debugger.connector_port=10137

First two lines(.so) should be exactly in this order. 前两行(.so)应该按此顺序排列。 Installing debugger "how to" easy to find in google. 安装调试器“如何”在谷歌中很容易找到。 No one mention above problem. 没有人提到上面的问题。

Update: 更新:

When I use the debugger it will go to the index.php. 当我使用调试器时,它将转到index.php。 I can step through for a while and see the value of variables. 我可以走一段时间,看看变量的价值。

This means you already have connection to server, problem is not there 这意味着您已经连接到服务器,问题不存在

I am doing remote PHP development with Eclipse and a "Synchronized PHP Project. Nothing except Eclipse is running on my computer. 我正在使用Eclipse和“同步PHP项目”进行远程PHP开发。除了Eclipse之外没有任何东西在我的计算机上运行。

This is your problem. 这是你的问题。 You have to allow xDebug connection. 您必须允许xDebug连接。 xDebug (PHP Web Server) trying to connect but probably have no idea where you are ;) xDebug(PHP Web服务器)尝试连接但可能不知道你在哪里;)

There two options: 有两种选择:

  1. If you are not behind NAT or in same network as your test server, you have to open port 9000 on your PC. 如果您不在NAT之后或与测试服务器位于同一网络中,则必须在PC上打开端口9000。 If you are behind NAT you need also forward port 9000 (this is default, can be changed). 如果您在NAT后面,您还需要转发端口9000(这是默认的,可以更改)。 Next set correct "xdebug.remote_host=your_public_ip" or xdebug.remote_connect_back = on . 接下来设置正确的"xdebug.remote_host=your_public_ip"xdebug.remote_connect_back = on Would be also good to enable accepting remote sessions (JIT) from any host (Preferences -> PHP -> Debug -> Debuggers -> xDebug), after this you will be able to easy run debugger via browser extension like xDebug helper. 从任何主机(首选项 - > PHP - >调试 - >调试器 - > xDebug)启用接受远程会话(JIT)也是很好的,之后您将能够通过浏览器扩展(如xDebug helper)轻松运行调试器。

  2. Configure debugger launch configuration (small arrow after "debug" icon"), to debug through SSH Tunnel. In this case xdebug.remote_host=127.0.0.1 will be correct. Note: ssh server host have to be same as server domain and SSH server have to be available on port 22 配置调试器启动配置(“debug”图标“后面的小箭头”),通过SSH隧道调试。在这种情况下, xdebug.remote_host=127.0.0.1将是正确的。 注意:ssh服务器主机必须与服务器域和SSH服务器相同必须在22号港口可用

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM