php7+xdebug+phpstorm配置
2022-09-02 本文已影响0人
简文猫

1.安装并配置xdebug
1.1安装
pecl包地址:https://pecl.php.net/package/xdebug
# 安装需要对应php版本包
[root@localhost ~]# pecl install https://pecl.php.net/get/xdebug-2.8.0.tgz
1.2 安装完成后,保存扩展路径

2.配置php.ini
[root@localhost ~]# vim /usr/local/etc/php/php.ini
# 添加xdebug配置
zend_extension=/usr/local/lib/php/extensions/no-debug-non-zts-20151012/xdebug.so
xdebug.remote_autostart = On
xdebug.idekey = PHPSTORM
xdebug.collect_params = 1
xdebug.collect_return = 1
xdebug.auto_trace = On
xdebug.trace_output_dir = "/data/php/logs/php.xdebug.trace"
xdebug.profiler_enable = On
xdebug.profiler_output_dir = "/data/php/logs/php.xdebug.profiler"
xdebug.remote_enable = On
xdebug.remote_host = 192.168.1.68
xdebug.remote_port = 9010
xdebug.remote_handler = dbgp
xdebug.remote_connect_back = on
xdebug.remote_log = "/data/php/logs/xdebug.log"
# xdebug.remote_host 需要改为自己的服务器地址
# xdebug.remote_port 需要改为自己的端口号
# xdebug.remote_log 需要改为自己的日志文件地址
# xdebug.trace_output_dir 需要改为自己的调试输出目录
# xdebug.profiler_output_dir 需要改为自己的分析器目录
# 目录配置均需要有权限可读可写!!!
# 注意需要开放端口号,否则会被防火墙拦截
3.配置phpstorm
3.1配置服务器

3.2配置PHP-调试-DBGp代理

3.3配置调试端口

3.4配置当前项目的调试

3.5测试是否配置成功

# 表示当前使用xdebug调试几种方式:
## 1.访问地址带参数
?XDEBUG_SESSION_START=PHPSTORM 为 xdebug 的ide_key标识
## 2.访问地址 header加Cookie
Cookie:XDEBUG_SESSION=PHPSTORM
## 3.浏览器集成插件 xdebug-helper
我们这里直接使用访问地址带参数
http://192.168.1.68:8001/?XDEBUG_SESSION_START=PHPSTORM
3.5.1在控制台可以看到输出
