PhpStorm Xdebug 配置与使用

一、安装 Xdebug 扩展

pecl install xdebug

file

二、Xdebug 配置

查看配置文件

php --ini

file

我们在 /usr/local/etc/php/7.2/conf.d 目录下新建一个 ext-xdebug.ini 配置文件,然后添加下列配置

[xdebug]
zend_extension="xdebug.so"
xdebug.profiler_enable=On
xdebug.profiler_enable_trigger=Off
xdebug.profiler_output_dir="/var/tmp/"
xdebug.trace_output_dir="/var/tmp/"
xdebug.profiler_output_name="xdebug.cache.%t-%s"
xdebug.profiler_append=Off
xdebug.remote_enable=On
xdebug.remote_host="localhost"
xdebug.remote_port=9001
xdebug.remote_handler="dbgp"
xdebug.idekey=PHPSTROM

0 或者 Off 代表关闭,1 或者 On 代表开启

xdebug.profiler_enable_trigger: 有关触发器的设置,关闭即可

xdebug.profiler_output_dir:Xdebug 日志记录的地址

xdebug.trace_output_dir:同 xdebug.profiler_output_dir,配置请填写一致

xdebug.profiler_output_name: 日志输出格式

xdebug.profiler_append: 关于附加设置,具体未知

xdebug.remote_enable: 远程调试功能,只要是与浏览器联调,请开启此功能

xdebug.remote_host: 联调的URL主机地址

xdebug.remote_port: 联调的请求端口

xdebug.remote_handler:调试函数,默认 dbgp,不要对其修改

xdebug.idekey:与 PhpStrom 连接时的确认口令,默认 PHPSTROM

重启php服务

valet restart

检查下xdebug配置是否生效

php -i | grep xdebug

file

三、PhpStorm配置

1、设置 Xdebug 端口

file

2、设置 PhpStorm Key、主机以及端口

file

3、新建 Xdebug 服务

file

4、配置 Xdebug 调试接口

file

file

四、运行测试

file

本作品采用《CC 协议》,转载必须注明作者和本文链接
《L01 基础入门》
我们将带你从零开发一个项目并部署到线上,本课程教授 Web 开发中专业、实用的技能,如 Git 工作流、Laravel Mix 前端工作流等。
《L05 电商实战》
从零开发一个电商项目,功能包括电商后台、商品 & SKU 管理、购物车、订单管理、支付宝支付、微信支付、订单退款流程、优惠券等
讨论数量: 2

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!