The most detailed debugging features original phpstorm add xdebug

Please indicate the source - https://www.cnblogs.com/TS-Alex/p/11302605.html 

1, the installation environment

php:7.2.21

xdebug Version: 2.7.2

phpstorm version: 2019.2

nginx Version: 1.12.2

2, the installation process

1, xdebug extended download

First through phpinfo () function to see the current version of php major concern following information

OK php compiler environment, and whether the operation of the system is thread-safe environment for me

MSVC15 (Visual C ++ 2017) x64 non-thread-safe

After the query above information to the official website to download the expansion xdebug

I was on a windows system to build a web service so I downloaded the windows version of the dynamic link library dll

Download as  https://xdebug.org/download.php

 

xdebug divided into many versions alpha version 2.8 and version 2.8 of betab here I downloaded the stable version 2.7.2 download which one to choose according to phpinfo information found in the beginning, my php VC15 X64 is not thread-safe version then on this version shown in the figure below downloads

 

2, xdebug mounting extension

1, download the file is a dll file, this file is renamed php_xdebug.dll

2. Place the file in php extensions folder inside the folder path is the home directory php - "ext folder

3, the folder is placed well to add this php extension,

Open the php.ini file add the following code in place of the extended edit


 

[Xdebug]
zend_extension=E:\LocalServer\php-7.2.21-nts-Win32-VC15-x64\ext\php_xdebug.dll     ;加载扩展的位置
xdebug.profiler_output_dir="E:\php-7.2.21-nts-Win32-VC15-x64\xdebug" 
xdebug.trace_output_dir="E:\LocalServer\php-7.2.21-nts-Win32-VC15-x64\tmp\xdebug"
xdebug.remote_log="E:\LocalServer\php-7.2.21-nts-Win32-VC15-x64\xdebug\log\xdebug.log" ;日志记录位置
xdebug.remote_port=9001 ;xdebug监听端口
xdebug.collect_params=on
xdebug.collect_return=0
xdebug.remote_enable=1  ;开启远程调试
xdebug.auto_trace=on
xdebug.profiler_enable = Off 
xdebug.profiler_output_name = cachegrind.out.%t.%p
xdebug.remote_autostart=Off
xdebug.remote_handler = "dbgp" ;传输协议
xdebug.remote_host=127.0.0.1  
xdebug.idekey = "PHPSTORM"  ;IDE关键字


 

配置好后重启 php_cgi服务重新加载phppe配置文件 

重新输出phpinfo信息如果看到如下信息既表名xdebug扩展添加成功

 3、phpstorm的配置

 添加成功后打开phpstorm 配置idea

注意这里有一个大坑 如果你的phpstorm版本是比较老的版本但是你的php 和xdebug的版本较新可能会导致调试卡死,是由于xdebug的xml命名空间变更的缘故,这里建议安装最新版本的phpstorm软件-我安装的是2019.2  (我以前用的phpstorm以前是10.0.2只能调试php5.x版本的代码 php版本换成7.x怎么都不能断点逐步调试,每次代码只能段在入口文件的第一行就卡死了最后web服务器返回504)

3.1、Setting配置

File->Setting->Languages & Frameworks

PHP

 

 Debug

 

 

 DBGp proxy

Servers-这个配置的server是我们运行调试时选择的server

3.2运行配置

点击菜单栏的 RUN->Web Server Debug Validation

进行如下如所示配置

当setting配置好后并且已经正确开启了nginx 和 php_cgi 服务后点击Validate 按钮会显示调试环境是否配置成功全部显示√既表示配置成功 

 

4、进行断点调试

要调试就需要发送请求

这里我发送请求的方式有两种 

4.1 POSTMAN 调试

使用POSTMAN 调试接口的时候需要对请求的接口添加如下header

Cookie:XDEBUG_SESSION=PHPSTORM

4.2使用Chrom调试

使用Chrom调试需要借助xdebug helper 插件 这个可以在插件商店下载到,安装好后进行如下配置

 

 

 

上述配置好后即可对调试的页面打断点调试了,在调试前记得开启监听点击这个按钮

配置下运行的server 并开启监听

 

 Note: Port 9000 is my native php_cgi xdebug occupied so I was listening port is configured to determine the pre-9001 port you are using is not occupied

Guess you like

Origin www.cnblogs.com/TS-Alex/p/11302605.html