php xdebug 不会在断点处停止
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4021964/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
xdebug won't stop at breakpoint
提问by RedPaladin
I spend some hours to set up my IDE to debug PHP with eclipse and xdebug.. Everything is ok except the breakpoint I set on eclipse. If I double-click on a line to add a breakpoint, the debugger want notto stop.. If a add the line xdebug_break() the debugger stops well at the line...
我花了几个小时来设置我的 IDE 以使用 eclipse 和 xdebug 调试 PHP。除了我在 eclipse 上设置的断点外,一切都很好。如果我上线双击添加断点,调试器想不来停止。如果一个添加行xdebug_break()调试器在该行停止以及...
It's maybe a problem with the configuration. Could anyone help me ?
可能是配置有问题。有人可以帮我吗?
- Eclipse: Eclipse PDT 2.2.0 All In Ones Windows 32 bits
- Xdebug: 5.3 VC6 (32 bit)
- PHP: PHP Version 5.3.3
- Eclipse:Eclipse PDT 2.2.0 All In Ones Windows 32 位
- Xdebug:5.3 VC6(32 位)
- PHP:PHP 版本 5.3.3
PHP.ini
配置文件
[xdebug]
xdebug.remote_enable=1
xdebug.remote_host=localhost
xdebug.remote_port=9000
xdebug.remote_handler="dbgp"
xdebug.remote_mode=req
xdebug.profiler_enable = 1
xdebug.profiler_output_dir = "c:/temp"
xdebug.collect_params = 4
xdebug.collect_return = on
xdebug.collect_vars = on
xdebug.show_local_vars = 1
回答by Freeman
If xdebug do not stop in any part of your code, add xdebug_break()
to this part of the code.
如果 xdebug 没有停止在您代码的任何部分,请添加xdebug_break()
到这部分代码中。
回答by Nanne
There seem to be several issues that could be the root of this problem. In my case it was the fact that I thought I needed to set some path mapping.
似乎有几个问题可能是这个问题的根源。就我而言,事实上我认为我需要设置一些路径映射。
The settings found underrightclick-project->properties->PHP Debug
and thenserver->edit->path mapping
were wrong.
下找到的设置rightclick-project->properties->PHP Debug
然后server->edit->path mapping
是错误的。
I had manually added something I though was correct, but Eclipse can do this all by its self it seems. Removing the mapping made it work.
我手动添加了一些我认为是正确的东西,但 Eclipse 似乎可以自己完成这一切。删除映射使其工作。
回答by Chriki
I've had a similar problem with Eclipse PDT and Xdebug. The cause was that Eclipse was listening via IPv6 but Xdebug tried to connect via IPv4:
我在 Eclipse PDT 和 Xdebug 上遇到了类似的问题。原因是 Eclipse 正在通过 IPv6 侦听,但 Xdebug 尝试通过 IPv4 连接:
chriki@machine:~$ netstat -an | grep 9000
tcp6 0 0 :::9000 :::* LISTEN
Xdebug doesn't seem to support IPv6, yet.
Xdebug似乎还不支持 IPv6。
After adding the line
添加行后
-Djava.net.preferIPv4Stack=true
after the -vmargs
line in my eclipse.ini
file, Eclipse started to listen via IPv4:
-vmargs
在我的eclipse.ini
文件中的这一行之后,Eclipse 开始通过 IPv4 进行侦听:
chriki@machine:~$ netstat -an | grep 9000
tcp 0 0 0.0.0.0:9000 0.0.0.0:* LISTEN
Debugging now works flawlessly.
调试现在完美无缺。
回答by RedPaladin
I have fixed myself the problem.
我已经解决了自己的问题。
On my php.ini, I have add the xdebug as an extension instead of a zend_extension.
在我的 php.ini 中,我添加了 xdebug 作为扩展而不是 zend_extension。
php.ini
配置文件
zend_extension=C:\EasyPHP-5.3.3\php\ext\php_xdebug.dll
Note: the path must be the full path instead of a relative path.
注意:路径必须是完整路径而不是相对路径。
The debugger works great. Yummy!
调试器运行良好。好吃!
回答by r00pert
I was having the same problem, PDT would start up the debug session, even breaking on the first line of the script and allowing stepping from there, but it would happily run through any manual breakpoints I had set if I clicked on Resume. After fiddling around with it and reading a bunch of other replies, I fixed it.
我遇到了同样的问题,PDT 会启动调试会话,甚至在脚本的第一行中断并允许从那里单步执行,但是如果我单击“恢复”,它会很高兴地运行我设置的任何手动断点。在摆弄它并阅读了一堆其他回复之后,我修复了它。
I had been trying to setup a Path Map (in the PHP server configuration) as my project path and web server paths were different, but this was not working for some reason so I ended up adding an alias to the apache config to match the location PDT was asking for. However, I had not removed this path map setting. When I removed the path map, breakpoints started to work!
我一直在尝试设置路径映射(在 PHP 服务器配置中),因为我的项目路径和 Web 服务器路径不同,但是由于某种原因这不起作用,所以我最终向 apache 配置添加了一个别名以匹配位置PDT 要求。但是,我没有删除此路径图设置。当我删除路径图时,断点开始工作!
Probably a symptom of something else not working properly ( the path map setting ) but breakpoints and debugging are all working for me now :)
可能是其他东西无法正常工作的症状(路径图设置),但断点和调试现在都对我有用:)
回答by Jekis
I had the same problem. The solution is to open correct file and add breakpoint in it.
我有同样的问题。解决方案是打开正确的文件并在其中添加断点。
My local server is on my virtual Z: drive (I'm using denwer instead of WAMP). Z drive points to my D:/webserver folder. So I can open my file as 1) Z:/myproject/script.phpand as 2) D:/webserver/myproject/script.php
我的本地服务器在我的虚拟 Z: 驱动器上(我使用的是 denwer 而不是 WAMP)。Z 驱动器指向我的 D:/webserver 文件夹。所以我可以打开我的文件 1) Z:/myproject/script.php和 2) D:/webserver/myproject/script.php
For some reasons debugger stops on breakpoints only in openned Z:/myproject/script.phpfile.
由于某些原因,调试器仅在打开的 Z:/myproject/script.php文件中的断点处停止。
How to test my solution??? Do next:
如何测试我的解决方案???接下来做:
- Open any php file you want to debug
- Add
xdebug_break()
to any line and save file - Run debug
- 打开任何要调试的 php 文件
- 添加
xdebug_break()
到任何行并保存文件 - 运行调试
In my case after debug process has started my phpDesigner IDE open correct file in IDE and stops at xdebug_break() line. So in this new opened file you can add breakpoints and they will work. Use opened file for debug.
在我的情况下,在调试过程启动后,我的 phpDesigner IDE 在 IDE 中打开正确的文件并在 xdebug_break() 行停止。因此,在这个新打开的文件中,您可以添加断点,它们将起作用。使用打开的文件进行调试。
回答by Kevin
This problem popped for me after moving some of my local project folders around. I could get xdebugger to break at the beginning of the file, but it would skip the rest of my breakpoints.
在移动我的一些本地项目文件夹后,这个问题突然出现。我可以让 xdebugger 在文件的开头中断,但它会跳过我其余的断点。
If you are using Netbeans, check that your Project Url ( Project Properties->Run Configuration ) points to the correct location. With the Project URL pointed to the right folder, breakpoints starting working as expected.
如果您使用的是 Netbeans,请检查您的项目 URL(项目属性->运行配置)是否指向正确的位置。随着项目 URL 指向正确的文件夹,断点开始按预期工作。
回答by Davide
I had the same problem for days (!) since I realized that the problem was the most trivial one.
好几天(!)我都遇到了同样的问题,因为我意识到这个问题是最微不足道的。
Configuration:
配置:
- (Windows 7 Host)
- Ubuntu 12.04 on VirtualBox Machine
- LAMP installed manually
- Eclipse Indigo + PDT
- php5-xdebug
- (Windows 7 主机)
- VirtualBox 机器上的 Ubuntu 12.04
- 手动安装 LAMP
- 日蚀靛蓝 + PDT
- php5-xdebug
/etc/php5/apache2/php.ini
/etc/php5/apache2/php.ini
[XDebug]
zend_extension="/usr/lib/php5/20090626+lfs/xdebug.so"
xdebug.remote_enable=true
xdebug.remote_host=127.0.0.1
xdebug.remote_port=9000
xdebug.remote_handler=dbgp
xdebug.profiler_output_dir=/tmp
The Debugger did't stop at breakpoints and neither at xdebug_break();
调试器不会在断点处停止,也不会在 xdebug_break();
...it was due to the default Apache DocumentRoot folder's /var/www
permissions
...这是由于默认的 Apache DocumentRoot 文件夹的/var/www
权限
I changed it to /home/user/Documents/www
.
我把它改成/home/user/Documents/www
.
回答by Fernando Terra
Quick answer: remove all white spaces on the path to your php script.
快速回答:删除 php 脚本路径上的所有空格。
Context:
There is a bug on PDT plug-in version 3.7.0 which prevents the debugger from stopping at breakpoints.
And it happens when the path to your script contains a white space!
It has been fixed but I guess the target version, which is 4.0.0, has not been released yet.
The comment which saved my day is at https://bugs.eclipse.org/bugs/show_bug.cgi?id=489646#c7("Comment 7").
上下文:
PDT 插件版本 3.7.0 存在一个错误,该错误会阻止调试器在断点处停止。
当您的脚本路径包含空格时,就会发生这种情况!
它已修复,但我猜目标版本 4.0.0 尚未发布。
拯救我一天的评论位于https://bugs.eclipse.org/bugs/show_bug.cgi?id=489646#c7(“评论 7”)。
回答by technocrusaders.com
This has been pissing me off for about 3 hours, just worked it out. So before you put a gun to your head, try this. When Eclipse starts, choose a new workspace, and setup your project again!
这让我生气了大约 3 个小时,刚刚解决了。所以在你把枪对准你的头之前,试试这个。当 Eclipse 启动时,选择一个新的工作空间,然后重新设置您的项目!
After I did this my break points got hit again! My break points were working fine, then all-of-a-sudden they stopped working. I Tried:
在我这样做之后,我的断点再次被击中!我的断点工作正常,然后突然他们停止工作。我试过:
removing all break points
cleaning project
re installing eclipse
删除所有断点
清洁工程
重新安装eclipse
NONE of the above worked for me!
以上都不适合我!
BTW I am using window 7.
顺便说一句,我正在使用窗口 7。
I hope this information saves someone's life!
我希望这些信息可以挽救某人的生命!
BTW: here are the steps you take to setup, centos 7 with xdebug and vmwere, with a window 7 client with eclipse:
顺便说一句:这里是你设置的步骤,centos 7 with xdebug 和 vmwere,带有 eclipse 的 window 7 客户端:
download vmwere
下载 vmwere
downlaod and setup vmwere with: CentOS-7-x86_64-Everything-1511.iso
下载并设置 vmwere:CentOS-7-x86_64-Everything-1511.iso
disable Firewall
禁用防火墙
systemctl disable firewalld
systemctl 禁用 firewalld
systemctl stop firewalld
systemctl 停止 firewalld
systemctl status firewalld
systemctl status firewalld
connect via ftp
通过ftp连接
ifconfig to find out Ip
ifconfig 找出IP
ifconfig
如果配置
eno16777736: flags=4163 mtu 1500
eno16777736:标志=4163 mtu 1500
inet 192.168.170.128 netmask 255.255.255.0 broadcast 192.168.170.255
inet 192.168.170.128 网络掩码 255.255.255.0 广播 192.168.170.255
inet6 fe80::20c:29ff:fec4:b8ca prefixlen 64 scopeid 0x20
inet6 fe80::20c:29ff:fec4:b8ca prefixlen 64 scopeid 0x20
ether 00:0c:29:c4:b8:ca txqueuelen 1000 (Ethernet)
以太 00:0c:29:c4:b8:ca txqueuelen 1000(以太网)
RX packets 254 bytes 20919 (20.4 KiB)
RX 数据包 254 字节 20919 (20.4 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
RX 错误 0 丢弃 0 溢出 0 帧 0
TX packets 95 bytes 10225 (9.9 KiB)
TX 数据包 95 字节 10225 (9.9 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
TX 错误 0 丢弃 0 溢出 0 载波 0 冲突 0
192.168.170.128 is the ip
192.168.170.128 是ip
setup LAMP
设置灯
rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY*
rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY*
yum -y install epel-release
yum -y 安装 epel-release
yum -y install mariadb-server mariadb
yum -y 安装 mariadb-server mariadb
systemctl start mariadb.service
systemctl 启动 mariadb.service
systemctl enable mariadb.service
systemctl 启用 mariadb.service
mysql_secure_installation
mysql_secure_installation
yum -y install httpd
yum -y 安装httpd
systemctl start httpd.service
systemctl 启动 httpd.service
systemctl enable httpd.service
systemctl 启用 httpd.service
yum -y install php
yum -y 安装php
service httpd restart
服务 httpd 重启
yum -y install php-mysql
yum -y 安装 php-mysql
yum -y install php-gd php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring
yum -y 安装 php-gd php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring
php-snmp php-soap curl curl-devel
php-snmp php-soap curl curl-devel
service httpd restart
服务 httpd 重启
yum install phpMyAdmin
yum 安装 phpMyAdmin
on windows open cmd, type ipconfig
在windows打开cmd,输入ipconfig
find
找
Ethernet adapter VMware Network Adapter VMnet8:
以太网适配器 VMware 网络适配器 VMnet8:
Connection-specific DNS Suffix . : localdomain
Link-local IPv6 Address . . . . . : fe80::94b8:9e5c:c772:3d47%19
IPv4 Address. . . . . . . . . . . : 192.168.170.1 [ this is the widnows ip to allow ]
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Default Gateway .
in /etc/httpd/conf.d/phpMyAdmin.conf change:
在 /etc/httpd/conf.d/phpMyAdmin.conf 更改:
AddDefaultCharset UTF-8
<IfModule mod_authz_core.c>
# Apache 2.4
<RequireAny>
Require ip 127.0.0.1
Require ip ::1
</RequireAny>
</IfModule>
<IfModule !mod_authz_core.c>
# Apache 2.2
Order Deny,Allow
Deny from All
Allow from 127.0.0.1
Allow from ::1
</IfModule>
to:
到:
AddDefaultCharset UTF-8
<IfModule mod_authz_core.c>
# Apache 2.4
<RequireAny>
Require ip 127.0.0.1
Require ip ::1
</RequireAny>
</IfModule>
<IfModule !mod_authz_core.c>
# Apache 2.2
Order Deny,Allow
Deny from All
Allow from 127.0.0.1
Allow from ::1
</IfModule>
<IfModule mod_authz_core.c>
# Apache 2.4
<RequireAny>
Require ip [ WINDOWS IP TO ALLOW GOES HERE ]
Require ip ::1
</RequireAny>
</IfModule>
<IfModule !mod_authz_core.c>
# Apache 2.2
Order Deny,Allow
Deny from All
Allow from [ WINDOWS IP TO ALLOW GOES HERE ]
Allow from ::1
</IfModule>
service httpd restart
服务 httpd 重启
change $cfg['Servers'][$i]['auth_type'] = 'cookie'; to $cfg['Servers'][$i] ['auth_type'] = 'http';
更改 $cfg['Servers'][$i]['auth_type'] = 'cookie'; 到 $cfg['Servers'][$i] ['auth_type'] = 'http';
service httpd restart
服务 httpd 重启
/etc/selinux/config change
/etc/selinux/config 更改
This file controls the state of SELinux on the system.
该文件控制系统上 SELinux 的状态。
SELINUX= can take one of these three values:
SELINUX= 可以采用以下三个值之一:
enforcing - SELinux security policy is enforced.
enforcing - 强制执行 SELinux 安全策略。
permissive - SELinux prints warnings instead of enforcing.
permissive - SELinux 打印警告而不是强制执行。
disabled - No SELinux policy is loaded.
禁用 - 未加载 SELinux 策略。
SELINUX=enforcing
SELINUX=强制执行
SELINUXTYPE= can take one of three two values:
SELINUXTYPE= 可以采用以下三个值之一:
targeted - Targeted processes are protected,
目标 - 目标进程受到保护,
minimum - Modification of targeted policy. Only selected processes are protected.
最低限度 - 修改目标政策。只有选定的进程受到保护。
mls - Multi Level Security protection.
mls - 多级安全保护。
SELINUXTYPE=targeted
SELINUXTYPE=目标
to
到
This file controls the state of SELinux on the system.
该文件控制系统上 SELinux 的状态。
SELINUX= can take one of these three values:
SELINUX= 可以采用以下三个值之一:
enforcing - SELinux security policy is enforced.
enforcing - 强制执行 SELinux 安全策略。
permissive - SELinux prints warnings instead of enforcing.
permissive - SELinux 打印警告而不是强制执行。
disabled - No SELinux policy is loaded.
禁用 - 未加载 SELinux 策略。
SELINUX=disabled
SELINUX=禁用
SELINUXTYPE= can take one of three two values:
SELINUXTYPE= 可以采用以下三个值之一:
targeted - Targeted processes are protected,
目标 - 目标进程受到保护,
minimum - Modification of targeted policy. Only selected processes are protected.
最低限度 - 修改目标政策。只有选定的进程受到保护。
mls - Multi Level Security protection.
mls - 多级安全保护。
SELINUXTYPE=targeted
SELINUXTYPE=目标
reboot centos
重启centos
IN WINDOWS POINT BROWSER TO: http://192.168.170.128/phpmyadmin, should be all good
在 WINDOWS 点浏览器中:http://192.168.170.128/phpmyadmin,应该都很好
copy website to: /var/www/html/[ WEBSITE NAME ]
复制网站到:/var/www/html/[网站名称]
chmod -R 777 html
chmod -R 777 html
in etc/httpd/ add ( this allows permalinks to work with post name )
在 etc/httpd/ 添加(这允许永久链接与帖子名称一起使用)
Options FollowSymLinks
选项 FollowSymLinks
AllowOverride All
允许覆盖所有
Order allow,deny
命令允许,拒绝
Allow from all
所有人都允许
yum install php-devel ( to allow pipsize )
yum install php-devel ( 允许 pipsize )
make php file with: and copy to website root run it and copy the htl into https://xdebug.org/wizard.phpthen click analysis source button
制作php文件:并复制到网站根目录运行它并将htl复制到https://xdebug.org/wizard.php然后单击分析源按钮
https://xdebug.org/wizard.phpwill give Instructions like this: ( follow them )
https://xdebug.org/wizard.php会给出这样的指令:(跟随他们)
...... Download xdebug-2.4.1.tgz
...... 下载 xdebug-2.4.1.tgz
Unpack the downloaded file with tar -xvzf xdebug-2.4.1.tgz
Run: cd xdebug-2.4.1
Run: phpize (See the FAQ if you don't have phpize.
Run: ./configure
Run: make
Run: cp modules/xdebug.so /usr/lib64/php/modules
Edit /etc/php.ini and add the lines
zend_extension = /usr/lib64/php/modules/xdebug.so
xdebug.remote_enable=On
xdebug.remote_host=192.168.170.1
xdebug.remote_port=9000
xdebug.remote_handler=dbgp
使用 tar -xvzf xdebug-2.4.1.tgz 解压下载的文件
运行:cd xdebug-2.4.1
运行: phpize (如果您没有 phpize,请参阅常见问题解答。
运行:./configure
运行:制作
运行:cp modules/xdebug.so /usr/lib64/php/modules
编辑 /etc/php.ini 并添加行
zend_extension = /usr/lib64/php/modules/xdebug.so
xdebug.remote_enable=开启
xdebug.remote_host=192.168.170.1
xdebug.remote_port=9000
xdebug.remote_handler=dbgp
..... service httpd restart
..... 服务 httpd 重启
run file and you should see an XDebug section, if so the server is ready to go!
运行文件,您应该会看到一个 XDebug 部分,如果是这样,服务器就可以运行了!
Download Eclipse Neon
下载 Eclipse Neon
File > Open projects from file system
文件 > 从文件系统打开项目
Finish ( and wait )
完成(并等待)
Window Preferences > php > servers > new
窗口首选项 > php > 服务器 > 新建
Server Tab
Server Name [ what ever you like ]
Base Url [ IP or name of your server ]
Document Root [ Location on your hard drive where all the code is, must be same as what you have on the server]
Debugger Tab
Debugger: Xdebug
port: 9000
Server Mapping tab ( click add)
Path on Server: [the whole path to your website] EG: /var/www/html/website
Path in Workspace [find the project you added with: Open projects from file system]
服务器选项卡
服务器名称 [你喜欢什么]
基本 URL [您的服务器的 IP 或名称]
文档根目录 [所有代码所在硬盘驱动器上的位置,必须与您在服务器上的位置相同]
调试器选项卡
调试器:Xdebug
端口:9000
服务器映射选项卡(单击添加)
服务器上的路径:[您网站的整个路径] EG:/var/www/html/website
工作区中的路径[找到您添加的项目:从文件系统打开项目]
go to eclipse main window > click drop down arrow beside the bug icon > debug configerations
转到 Eclipse 主窗口 > 单击错误图标旁边的下拉箭头 > 调试配置
Server Tab
File: [ this should be the first file in your local project that will be run when you app opens ]
URL: turn off auto generate : uncheck it
URL first text box: [ The IP or name of your server where you website is running ]
URL second text box: [ If your website is not in the root direcory, the direcory where it is goes here ]
Common Tab
Display in Favorites Menu
- Click Debug ( checkbox )
服务器选项卡
文件:[这应该是您本地项目中第一个将在您的应用程序打开时运行的文件]
URL:关闭自动生成:取消选中它
URL第一个文本框:[您网站运行的服务器的IP或名称]
URL第二个文本框:[如果您的网站不在根目录中,则它所在的目录在此处]
通用选项卡
在收藏夹菜单中显示
- 单击调试(复选框)
window > prespective > open prespective > php
窗口 > 预先 > 打开预先 > php
Put a break point in the php file that gets hit first ( by clicking on the vertial scrollbar on a line of code )
在首先被命中的 php 文件中放置一个断点(通过单击一行代码上的垂直滚动条)
Finally click the debug icon in eclipse, and your break point should get hit ( the line of code with the break point on it will go green )
最后点击 Eclipse 中的调试图标,你的断点应该被击中(带有断点的代码行会变成绿色)
Open up Centos 7 on Vemware to the world
向全世界开放 Vemware 上的 Centos 7
Change VMeere network setting to bridged
将 VMeere 网络设置更改为桥接
Add a rule to router to port foward any traffic to the vmweare IP that cetnos is running on
向路由器添加规则以将任何流量转发到 cetnos 运行的 vmweare IP
Add an inbound rule to the widnows firewall allowing http
向widnows防火墙添加一个允许http的入站规则
PS: I dont have time to check my gammer and speiing, deal with it
PS:我没有时间检查我的游戏机和 speing,处理它