实现环境:win10 x64
预先安装了xampp,这里安装的xampp 32位和64位都可以,只要对应的xdebug一致即可。
这里,如何安装xampp,并启动,就不谈了,很简单的。
1. 为php安装xdebug扩展
先确认php的版本7.2.5,32位。
去xdebug官网下载php扩展 https://xdebug.org/download.php ,xdebug有多个版本可以支持php7.2,2.6.1,2.7.0都可以
版本要对应好,php的Architecture:x86代表是32位的,Zend Extension Build:API320170718,TS,VC15,对应的xdebug应该是32位,带TS的版本, 将dll文件复制到xampp/php/ext/目录下。
修改php.ini文件,增加如下:
zend_extension="D:/xampp/php/ext/php_xdebug-2.6.1-7.2-vc15.dll"
[Xdebug]
xdebug.auto_trace = On
xdebug.show_exception_trace = On
xdebug.remote_autostart = On
xdebug.remote_enable = On
xdebug.collect_vars = On
xdebug.collect_return = On
xdebug.collect_params = On
xdebug.trace_output_dir="D:/xDebugLog"
xdebug.profiler_output_dir="D:/xDebugLog"
xdebug.profiler_enable=On
xdebug.remote_host=localhost
xdebug.remote_port=9000
xdebug.remote_handler=dbgp
这里注意一下,xdebug的remote_port=9000,这个端口可以修改,但是不能和apache的端口冲突,这个是xdebug专用的独立端口。
重启Apache后,可以在phpinfo中看到相关的信息,表示xdebug安装成功。
2.eclipse PDT配置php和xdebug
这里默认eclipse已经安装了PDT,如何安装PDT这里就不作说明了
2.1先配置服务器
注意,Base URL 和Document Root的值,就是Apache的配置数据
<VirtualHost *:8088>
DocumentRoot "D:/workspace/eclipse_php"
ServerName localhost
ServerAdmin admin@localhost
<Directory "D:/workspace/eclipse_php/">
#
# Possible values for the Options directive are "None", "All",
# or any combination of:
# Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
#
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.
#
# The Options directive is both complicated and important. Please see
# http://httpd.apache.org/docs/2.4/mod/core.html#options
# for more information.
#
Options Indexes FollowSymLinks Includes ExecCGI
#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# AllowOverride FileInfo AuthConfig Limit
#
AllowOverride All
#
# Controls who can get stuff from this server.
#
Require all granted
</Directory>
</VirtualHost>
当然,别漏了Listen 8088,对应的debugger方式,选择xdebug,端口要选择php.ini中remote_port的值
2.2 配置PHP的外部执行命令
2.3 配置Debug方式
选择【调试配置】
file选择启动文件路径,到这里,基本就算是配置完了
启动调试,设置断点,看到终端效果
这里仅说明PHP Web Application的调试模式,还有PHP CLI Application模式等,还有待研究