参考
https://blog.csdn.net/lurebreast/article/details/88350879
环境
本地环境:windows + php7.3
服务器环境:centos + php7.2
本地环境添加xdebug扩展
找到php配置文件php.ini,添加如下内容:
[xdebug]
zend_extension=C:/xxx/php7.3.4nts/ext/php_xdebug.dll ;xdebug扩展文件路径
xdebug.remote_enable=On ;启动远程调试,必须确定
xdebug.remote_host=127.0.0.1 ;需要调试的远程主机
xdebug.remote_port=9002 ;远程主机与phpstorm通信的端口,必须确定
linux服务器环境添加xdebug扩展
因yum未找到xdebug,故到https://xdebug.org/download/historical下载对应版本的xdebug文件(例:xdebug-3.1.6.tgz)
依次执行下面命令:
tar -xzf xdebug-3.1.6.tgz #解压xdebug文件
cd xdebug-3.1.6
phpize
./configure --enable-xdebug
make && make install
附图:
找到php配置文件,添加如下内容:
xdebug.mode=debug
xdebug.client_port=9002
zend_extension=xdebug
注:本地环境的remote_post和服务器环境的client_port的值要一致
使用xshell配置隧道代理
Xshell连接上服务器(注:测试时,该连接不能中断)
设置phpstorm
phpstorm主界面打开“File”->“Setting”
Phpstorm右上角,如图:
点击“绿色的甲壳虫”按钮,开始监听
将“?XDEBUG_SESSION_START=18655”拼接到我们需要测试的接口后边
打上断点,查看结果
附
Validate验证设置是否正确