配置PhpStorm调试PHP

配置PhpStorm调试PHP

第一步:配置 XDebug

下载安装XDebug到本地环境(参考:Zend Studio 9.x + xampp + XDebug 调试环境安装详解),打开php.ini,参考配置如下:
[XDebug]
zend_extension = "D:PHPxampp2phpextphp_xdebug.dll"
xdebug.profiler_append = 0
xdebug.profiler_enable = 1
xdebug.profiler_enable_trigger = 0
xdebug.profiler_output_dir = "D:PHPxampp2 mp
xdebug.profiler_output_name = "cachegrind.out.%t-%s"
xdebug.remote_enable = 1
xdebug.remote_handler = "dbgp"
xdebug.remote_host = "127.0.0.1"
xdebug.remote_port=9000
xdebug.trace_output_dir = "D:PHPxampp2 mp"

备注:

PHPstudy等集成环境已经在各个版本中集成了xdebug,只需要在PHP拓展中勾选xdebug然后重启服务即可直接使用。

第二步:配置PhpStorm中的 XDebug

路径:File -> Settings -> Languages & Frameworks -> PHP -> Debug

phpstrom-debug-02.png

第三步:配置PhpStorm中的 Server

路径:File -> Settings -> Languages & Frameworks -> PHP -> Servers

phpstrom-debug-01.png

注意:如果所谓的“远程服务器”就在本地的话,就不需要勾选“Use path mappings(select if the servers is remote or symlinks are used)”

第四步:设置调试项

点击 如下图所示的“下三角”按钮,选择 “Edit Configurations”,弹出“Run/Debug Configrations”对话框:

phpstrom-debug-03.png

phpstrom-debug-04.png

第五步:开始调试页面

点击工具栏上的“电话按钮”,开启调试端口的监听,然后点击“甲壳虫按钮”,开始调试页面。

phpstrom-debug-05.png

特别说明下:因为刚才设置的是:开启调试的时候,打开项目的“首页”,所以当点击“甲壳虫按钮”后,它会打开“首页”。

不用管它打开了“首页”,上面的动作只是为了开启PhpStorm的调试监听功能,当我们在浏览器中输入要调试的页面时(记得按“回车键”),如页面 http://127.0.0.4:8088/home/Test/test,它会自动跳转页面的断点处,如下图所示:

phpstrom-debug-06.png

点击调试按钮,一步一步调试吧(快捷键 F5)!

常用的几个快捷键

F5:Step Into

F6:Step Over

F7:Step Out

参考:

https://www.adayinthelifeof.nl/2012/12/20/debugging-remote-cli-with-phpstorm

延伸阅读:

【总结2】PhpStorm利用XDebug调试PHP技巧

相关日志:

VirtualBox安装CentOS5.x中出现NET:Registered protocol family 2后卡住问题

【总结2】PhpStorm利用XDebug调试PHP技巧

初学UML用哪个case工具?Rational Rose2007(v7.0)破解版下载

Intellij IDEA 14.x 中的Facets和Artifacts的区别

解决XP下“无法通过windows installer服务安装此安装程序包。您必须安装带有更新版本Windows Installer服务的Windows Service Pack。”的问题

PHP最强大开发工具PhpStorm注册码收藏

【强烈推荐】利用NAT、Host-Only双虚拟网卡,实现Virtual Box中CentOS6.3联网

Zend Studio / Ecliplse插件EasyExplorer,打开资源文件所在的文件夹

Windows主机里利用VMware安装Linux(CentOS)虚拟机,Host-only连接上网方式详解

Git的load putty key选项不可用(why-load-putty-key-is-disabled-in-tortoise-git)

文章转载自:http://blog.snsgou.com/post-825.html

原文地址:https://www.cnblogs.com/farcall/p/4897782.html