phpstorm 配置xdebug

13次阅读

共计 1264 个字符,预计需要花费 4 分钟才能阅读完成。

最近买了个新本,重新配置下 phpstorm xdebug, 方便调试
提高调试效率是写程序的第一步 — 鲁迅
自 2018 年 3 月份之后,brew 安装 php 的方式发生改变,现在是
brew install php@7.2
可以指定版本了,安装扩展的方式也完全不能用了,所以下载源码编译了

下载 xdebug
官网:https://xdebug.org/download.php

下载最稳定的版本 [版本 2.6.1][1]

编译源码
phpize
./configure –with-php-config=/usr/local/Cellar/php@7.2/7.2.16/bin/php-config
make && make install

Installing shared extensions: /usr/local/Cellar/php@7.2/7.2.16/pecl/20170718/

编译到了这个目录,实际软连到了 /usr/local/lib/php/pecl

配置 xdebug
在 /usr/local/etc/php/7.2/conf.d 新建 ext-xdebug.ini 写入
[xdebug]
zend_extension=”/usr/local/lib/php/pecl/20170718/xdebug.so”
xdebug.remote_enable=On
xdebug.remote_connect_back=1
xdebug.remote_port=6677
xdebug.remote_log=/usr/local/var/log/xdebug.log
xdebug.idekey=PHPSTORM

xdebug.idekey = mykey ide key,用于标识调试会话
xdebug.remote_autostart 是否自动启动,1: 自动,0: 需要设置 http 请求参数或 cookie 指定,默认 0,根据需求设置这个值。个人建议设置为 1,这样不需要在每个需要调试的接口都修改请求参数
xdebug.remote_enable = on 是否开启远程调试
xdebug.remote_host = 172.16.10.103 远程主机 IP,也就是 PHPStorm 所在机器(PHPStorm 作为 xdebug client),没有固定 IP 的机器建议使用 connect_back 选项。
xdebug.remote_connect_back = on 是否连接回请求发出的主机,如果 PHPStorm 所在的机器 IP 经常变动(DHCP 环境下),则建议开启这个选项
xdebug.remote_port = 10000 远程主机端口,也就是开发者机器端口
xdebug.idekey=PHPSTROM 和 phpstorm 通信的标识

重启 php, 查看是否安装成功
/usr/local/etc/php/7.2/conf.d php -m | grep xdebug
搞定!!
开始配置 phpstorm 设置端口设置 servers

配置 debug config

访问 url?XDEBUG_SESSION_START=PHPSTORM, 搞定

哈哈哈,配色有点浮夸,还没调

正文完
 0