likes
comments
collection
share

Webman + XDebug 3.0 + PHPStorm调试

作者站长头像
站长
· 阅读数 21

PHP的debug3.0配置文件

[xdebug]
zend_extension="/opt/homebrew/opt/xdebug@8.1/xdebug.so"
# 以下新增
xdebug.mode=debug
xdebug.client_host=127.0.0.1
xdebug.client_port="9003"
xdebug.remote_handler=dbgp
;xdebug.start_with_request=yes
xdebug.show_local_vars = 1

PHPStorm里的设置

Servers设置

Webman + XDebug 3.0 + PHPStorm调试

CLI Interpreters配置,注意Debugger那里,必须要有Xdebug的信息

Webman + XDebug 3.0 + PHPStorm调试

Debug相关设置

Webman + XDebug 3.0 + PHPStorm调试

注意这里的Port端口与xdebug.client_port 端口号相对应

Webman + XDebug 3.0 + PHPStorm调试

HOST文件配置

vim /etc/hosts增加条目

127.0.0.1 yoursite.test

启动

方式一:打开小电话监听,直接在命令终端中执行

  1. PHPStorm里

Webman + XDebug 3.0 + PHPStorm调试

  1. 终端里
export XDEBUG_SESSION=1
#进入项目
php start.php start #启动

ctrl+c 中止

方式二:使用phpstorm内置的按钮

1. 创建一个配置

Webman + XDebug 3.0 + PHPStorm调试

Webman + XDebug 3.0 + PHPStorm调试 这里把参数改成 restart,解决重复启动的问题。 Webman + XDebug 3.0 + PHPStorm调试

2. 启动

正常开发的时候按小▶️ 启动。

需要调试的时候,先打开小电话📞,然后点击虫子按钮

在浏览器里或者curl访问特定的路由

Webman + XDebug 3.0 + PHPStorm调试

3. 停止

点击 Stop All Webman + XDebug 3.0 + PHPStorm调试


PS:要提醒一点,如果打开小电话监听,webman就无法热重载了。不需要debug的时候请关闭小电话,

至于出现如下的提示:

Xdebug: [Step Debug] Could not connect to debugging client. Tried: 127.0.0.1:9003 (through xdebug.client_host/xdebug.client_port) :-(

只是告诉你,php在启动的时候要去连接9003的端口,没有连接上,并不影响正常的开发。这个消息在啥时候需要关注呢?就是当你的小电话打开了,还提示这个问题,你就想思考是不是IP和端口设置的有问题了。

转载自:https://juejin.cn/post/7247058712196071480
评论
请登录