配置 Phpstorm + Xdebug + xampp
1 Xampp
安装好xampp,配置 httpd.conf
在xampp面板中![](file:///C:/Users/Administrator/AppData/Local/YNote/data/sunlianqun555@163.com/4a87fd2f5c434b9caad9294a0ae23248/b20.tmp.png)
![](file:///C:/Users/Administrator/AppData/Local/YNote/data/sunlianqun555@163.com/4a87fd2f5c434b9caad9294a0ae23248/b20.tmp.png)
单击后会出现一些配置文件,httpd.conf位于第一个
将DocumentRoot 路径改为 "G:/PHP" (我的工作空间),以后项目就放在这个目录里。
配置 php.ini(打开方式如上)
在Windows 下的配置:(这些代码位于php.ini的最后,将原来的带;的代码覆盖成以下所提供的就能够,此时执行phpinfo()函数能够看到在配置中有Xdebug)
[XDebug]
zend_extension = "D:XAMPPphpextphp_xdebug.dll"
xdebug.profiler_append = 0
xdebug.profiler_enable = 0
xdebug.profiler_enable_trigger = 0
xdebug.profiler_output_dir = "D:XAMPP mp"
xdebug.profiler_output_name = "cachegrind.out.%t-%s"
xdebug.remote_enable = 0
xdebug.remote_handler = "dbgp"
xdebug.remote_port=9000
xdebug.remote_host = "127.0.0.1"
xdebug.trace_output_dir = "D:XAMPP mp"
xdebug.idekey= PHPSTROM
上述配置中若开启profiler_enable的话本地訪问会变非常慢。
配置完后重新启动apache ,查看phpinfo信息会看到xdebug已经开启了。若没有请查看xdebug.dll 和自己的php版本号是否相符合。
2.在chrome页面的扩展程序中加入xdebug helper。
3 PhpStorm设置
在File->settings中![](http://img.blog.csdn.net/20150723150342350?</p><p>watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center)
![](file:///C:/Users/Administrator/AppData/Local/YNote/data/sunlianqun555@163.com/e9180baa7d44460d827a57474b25068d/112c.tmp.png)
如图所看到的配置setting中的4个地方,最后在图片所看到的的localhost位置单击(若没有在这里配置过。那么会没有内容显示)![](file:///C:/Users/Administrator/AppData/Local/YNote/data/sunlianqun555@163.com/bfef3d1838074e41abd8431464d81d0b/clipboard.png)
![](file:///C:/Users/Administrator/AppData/Local/YNote/data/sunlianqun555@163.com/bfef3d1838074e41abd8431464d81d0b/clipboard.png)
单击editconfiguration,能够看到例如以下所看到的
![](file:///C:/Users/Administrator/AppData/Local/YNote/data/sunlianqun555@163.com/48fa67f9d0a54daa859f4d08c8942a66/13b2.tmp.png)
右側的port能够填写8789等4位数。
如今就能够执行你的程序啦。如在网址中打,localhost:8789/index.php(如果你的根文件夹下的index.php是你的项目的入口)。
4.要调试的时候打开phpstorm中右上角的监听。例如以下图所看到的。打开会变绿色。
5.chrome右上角的xdebug图标。单击debug。图案会变绿。
6.此时在你的代码中将你想要调试的代码的行号处设置断点。执行断点相关代码。调试就会进行.编辑器下方会出现调试信息。