使用phpstrom 和 xdebug 调试PHP程序

栏目: PHP · 发布时间: 6年前

内容简介:使用phpstrom 和 xdebug 调试PHP程序

平时使用 php 调试程序,都是使用 var_dump()print_r()echo 等函数,这样调试起来效率很低,php提供了 xdebug 扩展,来帮我我们调试。

利用ide 和 xdebug ,可以实现像平时调试 Java 一样的效果。

安装 xdebug 扩展

Mac环境下可以使用 homebrew 直接下载安装,Windows环境去 Xdebug 下载安装。

注意:不论是用 homebrew 安装,还是自己下载安装,安装完毕后,默认和调试相关的 xdebug_remote_enable 设置是不开启的。可以通过 phpinfo 查看 xdebug 扩展是否开启。

设置 xdebug 扩展

找到 php.ini 文件,(用 homebrew 安装的修改 /usr/local/etc/php/7.1/conf.d 目录中的 ext-xdebug.ini 文件就好)主要设置以下参数:

xdebug.remote_enable = on //设置xdebug扩展远程开启
xdebug.idekey="PHPSTORM" //注意这里添的值,phpstorm中要一致
xdebug.remote_port=9001 //这一点至关重要,默认是9000会和默认的php-fpm端口冲突

设置phpstorm

设置phpstorm上的xdebug端口

使用phpstrom 和 xdebug 调试PHP程序

9001xdebug 扩展中 xdebug.remote_port 的值

设置phpstorm上的xdebug idekey

使用phpstrom 和 xdebug 调试PHP程序

IDE key的值要和 xdebug.idekey 的值一致,port的值要和你即将访问的网站端口一致

添加一个server

使用phpstrom 和 xdebug 调试PHP程序

使用phpstrom 和 xdebug 调试PHP程序

Run/Debug Configurations

使用phpstrom 和 xdebug 调试PHP程序

使用phpstrom 和 xdebug 调试PHP程序

选择的server为刚才创建的那个server

使用phpstrom 和 xdebug 调试PHP程序

使用phpstrom 和 xdebug 调试PHP程序 一定要选择建图中所标的 web application 而不是 remote xdebug

使用phpstrom 和 xdebug 调试PHP程序


以上所述就是小编给大家介绍的《使用phpstrom 和 xdebug 调试PHP程序》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

Hatching Twitter

Hatching Twitter

Nick Bilton / Portfolio Hardcover / 2013-11-5 / USD 28.95

The dramatic, unlikely story behind the founding of Twitter, by New York Times bestselling author and Vanity Fair special correspondent The San Francisco-based technology company Twitter has become......一起来看看 《Hatching Twitter》 这本书的介绍吧!

JSON 在线解析
JSON 在线解析

在线 JSON 格式化工具

HTML 编码/解码
HTML 编码/解码

HTML 编码/解码

Base64 编码/解码
Base64 编码/解码

Base64 编码/解码