phpstorm+xdebug搭建

phpstorm配合xdebug进行调试会大大提高开发效率,但是从头安装环境会有些麻烦,下边记录一下整修操作过程:

1:安装xdebug

之前版本的MAC安装xdebug直接就brew install xdebug就可以了,但是现在不是在brew里边

需要执行:

pecl install xdebug

PECL的安装可以自行百度

xdebug安装完成后需要将xdebug的文件夹

从/usr/local/lib/php/pecl

移动到 /usr/local/Cellar/php/7.2.8/lib/php/ 目录下

执行

php --version

执行完该行命令如果在输出中有xdebug相关信息,那说明xdebug已经安装完成

配置php.ini

; prefix => /usr/local/etc/php/5.4/
; 该参数是要加载的 xdebug.so 模块,具体是 ext 可以到
; /usr/local/etc/php/5.4/ext 去查看详情,默认会有扩展的目录
; 该配置配置于:conf.d/ext-xdebug.ini
; zend_extension = ext/xdebug.so
; 远程是否可以用,必须
xdebug.remote_enable = on
; 远程的 host,默认本地,然后可以配置为 vagrant 的地址
xdebug.remote_host = 127.0.0.1
; 使用非 9000 默认端口,9000 端口我失败了,所以最好改动一下,避免 fuck
xdebug.remote_port = 9010
; 使用 dbgp 做 80 端口代理
xdebug.remote_handler = dbgp
; 这里的 的 key 必须和到时候 IDE 中的一致
xdebug.idekey = PHPSTORM
; 输出的日志文件,个人觉得很重要
xdebug.remote_log = /tmp/xdebug.log

配置 PhpStorm 工具

可以参考文章:

https://segmentfault.com/a/1190000006917029

如果调度工具采用的是postman

那么一定要注意:在请求的header中的key要设为Cookie, value要设为XDEBUG_SESSION=PHPSTORM

原文地址:https://www.cnblogs.com/wlemory/p/9867260.html