下载xdebug扩展 将phpinfo()中的信息全部复制到Xdebug中的文本框中,如下图所示:点击“Analyse my phpinfo() output”按钮。

跳转到如下图所示页面,会对本机中的php进行分析,点击“Download php_xdebug-2.7.2-7.2-vc15-x86_64.dll”按钮下载Xdebug扩展。

配置Xdebug扩展 将下载好的Xdebug扩展复制到php目录下的ext文件夹中,并在php.ini配置的末尾添加如下配置信息:
zend_extension=E:\php7\ext\php_xdebug-2.7.2-7.2-vc15-x86_64.dll
xdebug.profiler_output_dir="E:\php\xdebug"
xdebug.trace_output_dir="E:\php\xdebug"
xdebug.remote_port=9000
xdebug.idekey=PHPSTORM
xdebug.remote_autostart=1
xdebug.remote_host=localhost
xdebug.remote_enable=1
然后重启服务,再次打开phpinfo(),出现xdebug扩展表示配置成功

phpStorm中配置Xdebug 在常用的编辑器中配置xdebug,以phpstorm为例,打开“File->Settings->Languages & Development->PHP->Debug”,配置XDebug监听端口号,需要与在php.ini配置文件中配置的端口号保持一致,如下图所示:

打开“File->Settings->Languages & Development->PHP->Debug->DBGp Proxy”,配置DBGp协议配置信息,如下图所示:

打开“File->Settings->Languages & Development->PHP->Server”,配置php运行服务器,如下图所示:

打开“Run/Debug Configurations”,添加“PHP Web Page”,如下图所示:

Chrome添加Xdebug helper扩展 Chrome添加完Xdebug helper扩展后,需要配置"IDE key",需要与php.ini配置文件中配置的保持一致。上面配置文件写的是PHPSTORM

开启phpStorm调试 首先设置运行服务器为localhost,然后打开php debug监听,运行debug模式,最后设置断点,如下图所示:

最后 如果你觉得这篇文章对你有点用的话,麻烦请给我们的开源项目点点star:http://github.crmeb.net/u/defu不胜感激 !
免费获取源码地址:http://www.crmeb.com
PHP学习手册:https://doc.crmeb.com
技术交流论坛:https://q.crmeb.com
|