PhpStorm配置Xdebug

      最近用着PhpStorm来写PHP代码,感觉很不错。最近在准备调试PHP代码的时候,找到了在ZendStudio下同样用到的Xdebug。这篇文章仅是PhpStorm下配置Xdebug的简介,没啥技术含量,留个笔记,后续备查。

      本机环境:Win7 X64+XAMPP(PHP版本为5.6.3)。

      首先下载PHP版本对应的Xdebug版本,我这里下载PHP 5.6 VC11 TS (64bit)版本,其中的TS为线程安全版本。

      下载之后的文件拷贝到PHP目录下的ext文件夹中,然后配置php.ini文件。

      具体配置如下:

zend_extension = "F:xamppphpextphp_xdebug.dll"
;xdebug.profiler_append = 0
xdebug.profiler_enable = 1
;xdebug.profiler_enable_trigger = 0
;xdebug.profiler_output_dir = "F:xampp	mp"
;xdebug.profiler_output_name = "cachegrind.out.%t-%s"
xdebug.remote_enable = 1
xdebug.remote_mode = "req"
xdebug.remote_handler = "dbgp"
xdebug.remote_port=9000
xdebug.idekey="PHPSTORM"
xdebug.remote_host = "localhost"
xdebug.trace_output_dir = "F:xamppapachexdebug	race"
xdebug.profiler_output_dir="F:xamppapachexdebugprofiler"

      在这里的zend_extension为xdebug动态链接库所存放的路径。

      然后,重启Apache服务器,在phpinfo中可以看到Xdebug的一些配置信息,则说明配置成功。

xdebug

      接下来,配置PhpStorm。进入File->Settings->PHP->Servers,这里填写服务器相关信息。Name填localhost,Host填localhost,Port填80,Debugger选Xdebug。如下图所示:

xdebug2

      进入File->Settings->PHP->Debug,看到XDebug选项卡,Debug port填9000,其他默认。如下图所示:

xdebug3

      进入File->Settings->PHP->Debug->DBGp Proxy,IDE key填PHPSTORM,Host填localhost,Port填80.

xdebug4

      点击OK退出设置。

      打开浏览器,安装Xdebug插件。我使用的是Firefox,安装的插件为The Easiest Xdebug。具体设置如下图所示:

xdebug5

      这样,配置基本完成了。

      在PhpStorm里打开监听,就是工具栏里面像一个电话一样的按钮。

      在浏览器里打开Xdebug工具,访问localhost与PhpStorm连接成功。后续如果需要调试某个页面中的内容,在PhpStorm中设置好断点,然后在打开Xdebug的浏览器中访问调试页面即可进入调试了。

好了,就这么多。

原文地址:https://www.cnblogs.com/hiccup/p/5423968.html