- 时间:2020-01-25 04:54 编辑: 来源: 阅读:
- 扫一扫,手机访问
摘要:PHPStorm+XDebug进行调试图文教程
笔者的开发环境如下:Windows8.1+Apache+PhpStorm+XDebug+Firefox(XDebug helper 1.4.3插件)。
[b]一、XDebug安装配置[/b]
(1)下载XDebug下载地址:[url=http://www.xdebug.org/]http://www.xdebug.org/[/url]必须下载跟机器上安装的php匹配的版本才行。具体下载方法如下:将phpinfo网页的源代码拷贝到[url=http://www.xdebug.org/find-binary.php]http://www.xdebug.org/find-binary.php[/url],然后按照指导安装即可。如下图所示:
[img]http://files.jb51.net/file_images/article/201606/2016061308594310.jpg[/img]
[img]http://files.jb51.net/file_images/article/201606/2016061308594311.jpg[/img]
(2)安装XDebug按照上图下载“php_xdebug-2.3.2-5.4-vc9.dll”,将其复制到d:\php\ext\目录。
(3)配置XDebug打开d:\php\php.ini,在末尾增加如下代码:
[Xdebug]
zend_extension = d:\php\ext\php_xdebug-2.3.2-5.4-vc9.dll
xdebug.remote_enable =1
xdebug.remote_handler = "dbgp"
xdebug.remote_host = "localhost"
xdebug.remote_mode = "req"
xdebug.remote_port = 9000
重启Apache。
(4)验证安装是否成功检测方法1:在phpinfo网页中,能够检索到XDebug字样,就安装成功了,如下图所示:
[img]http://files.jb51.net/file_images/article/201606/2016061308594312.jpg[/img]
[b]检测方法2:[/b]
在cmd下输入php -m,能看到XDebug说明配置成功。如下图所示:
[img]http://files.jb51.net/file_images/article/201606/2016061308594313.jpg[/img]
[b]二、PHPStorm中XDebug配置在【File】->【Settings】->【Languages & Frameworks】->【PHP】的Setting中:[/b]
(1)配置PHP Server找到【Servers】,配置项如下: Name:localhostHost:localhostPort:80Debugger:XDebug如下图所示:
[img]http://files.jb51.net/file_images/article/201606/2016061308594414.jpg[/img]
(2)配置PHP Debug找到【Debug】,XDebug中的Debug Port填写9000,其它默认。如下图所示:
[img]http://files.jb51.net/file_images/article/201606/2016061308594415.jpg[/img]
[b]三、Fireforx中XDebog helper插件的配置[/b]
(1)安装XDebug helper插件如下图所示:
[img]http://files.jb51.net/file_images/article/201606/2016061308594416.jpg[/img]
(2)配置XDebug helper插件在上图中,点击【选项】,然后按照如下进行配置:IDE key:PhpStormDomain filter:
localhost如下图所示:
[img]http://files.jb51.net/file_images/article/201606/2016061308594417.jpg[/img]
[b]四、使用XDebug调试方法及步骤[/b]
(1)在PHPStorm中开启Debug监听点击那个像电话一样的图标即可开启Debug监听,如下图所示:
[img]http://files.jb51.net/file_images/article/201606/2016061308594418.jpg[/img]
(2)在Chrome浏览器中开启XDebug helper插件
[b]方法一:[/b]在地址栏中,点击那个的虫子,选择Debug,如下图所示:
[img]http://files.jb51.net/file_images/article/201606/2016061308594419.jpg[/img]
[b]方法二:[/b]使用快捷键:CTRL+SHIFT+X进行配置。
(3)在PHPStorm中设置断点在行号后面空白处单击即可设置断点。
(4)断点调试然后在浏览器中引导到相应的断点处的方法即可自动被断下来,如下图所示:
[img]http://files.jb51.net/file_images/article/201606/2016061308594420.jpg[/img]
红色框框中有所有的断点处理方式及快捷键提示。
以上就是本文的全部内容,希望对大家学习PHP调试教程有所帮助。