您的位置:首页 > 编程语言 > PHP开发

PHP调试利器XDebug Mac下在phpstorm中的安装与使用

2018-03-23 21:16 721 查看
转载自:https://ifunbox.top/mac_php_xdebug_phpstorm_install

之前一直用比较原始的调试方法echo、print_r()、var_dump()、printf(),可能小项目比较小吧最近有时间,就研究了Mac系统下集成phpstorm的xdebug安装配置使用,下面记录一下~

安装篇

1.xdebug的安装下载地址https://xdebug.org/我是直接用神器brew安装(版本号自行替换)brew install homebrew/php/php56-xdebug安装完毕后brew info homebrew/php/php56-xdebug 包含了很多信息 包括xdebug的配置文件路径,如何判断安装成功等等

2.配置xdebug在/usr/local/etc/php/5.6/conf.d/ext-xdebug.ini[xdebug]
zend_extension="/usr/local/opt/php56-xdebug/xdebug.so"
xdebug.remote_enable=1
xdebug.remote_host="127.0.0.1"
xdebug.remote_port=9001
xdebug.profiler_enable=1
xdebug.profiler_output_dir="/Users/www/debug"
xdebug.idekey="PHPSTORM"3.在phpstorm中配置xdebug





上面都配置好后要在主菜单中,选择Run | Web Server Debug Validation.下图是验证成功的效果,但是没有那么顺利,报错Remote host is configured as “localhost” despite server host is probably not local,在stackoverflow有人说把xdebug.remote_host改成自己项目的域名就可以了,还真是不知道是为何。。。

4.phpstorm配置一个PHP Web Application

5.打开Chrome下载安装xdebug-helper,地址https://chrome.google.com/webstore/detail/xdebug-helper/eadndfjplgieldjbigjakmdgkmoaaaoc点开选项记得把IDE key配置得跟之前设置的一样

到这里安装配置就结束了~~~

使用篇

1.phpstorm 打开监听 Run | Start Listening For PHP Debug Connections2.打个断点3.访问项目域名,就可以在phpstorm中看到变量信息,点击红框,可以查看每次执行的代码行,也会看到因为执行代码行所赋值的变量。

还有一个就是php报错的时候回显示堆栈信息

参考https://www.jetbrains.com/help/phpstorm/2016.2/configuring-xdebug.htmlhttp://stackoverflow.com/questions/36001918/phpstorm-xdebug-remote-host-is-configured-as-localhost-despite-server-host
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: