brew install php56-xdebug,[转]mac +brew+phpstorm+xdebug 安装配置及使用

安装篇

1.xdebug的安装

下载地址https://xdebug.org/

我是直接用神器brew安装(版本号自行替换)

brew install homebrew/php/php56-xdebug

安装完毕后brew info homebrew/php/php56-xdebug 包含了很多信息 包括xdebug的配置文件路径,如何判断安装成功等等

e4703199b857?utm_campaign=maleskine&utm_content=note&utm_medium=seo_notes&utm_source=recommendation

2.配置xdebug

在/usr/local/etc/php/5.6/conf.d/ext-xdebug.ini (5.6为安装版本,根据你实际安装的版本来设置)[xdebug]

zend_extension=”/usr/local/opt/php56-xdebug/xdebug.so”

xdebug.remote_enable=1

xdebug.remote_host=”www.xxx.com″

xdebug.remote_port=9001

xdebug.profiler_enable=1

xdebug.profiler_output_dir=”/Users/www/debug”

xdebug.idekey=”PHPSTORM”

注意:修改了配置后一定要重启服务,如果是apache就重启apache,如果是php-fpm就需要重启php-fpm,否则配置不会生效

3.在phpstorm中配置xdebug

e4703199b857?utm_campaign=maleskine&utm_content=note&utm_medium=seo_notes&utm_source=recommendation

选择brew安装的PHP版本

e4703199b857?utm_campaign=maleskine&utm_content=note&utm_medium=seo_notes&utm_source=recommendation

端口号要对应

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

e4703199b857?utm_campaign=maleskine&utm_content=note&utm_medium=seo_notes&utm_source=recommendation

验证成功图

4.phpstorm配置一个PHP Web Application

e4703199b857?utm_campaign=maleskine&utm_content=note&utm_medium=seo_notes&utm_source=recommendation

5.打开Chrome下载安装xdebug-helper,地址https://chrome.google.com/webstore/detail/xdebug-helper/eadndfjplgieldjbigjakmdgkmoaaaoc

点开选项记得把IDE key配置得跟之前设置的一样

e4703199b857?utm_campaign=maleskine&utm_content=note&utm_medium=seo_notes&utm_source=recommendation

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

使用篇

1.phpstorm 打开监听 Run | Start Listening For PHP Debug Connections (在 phpstorm 2016.2上测试,不打开监听也可以debug)

2.打个断点

e4703199b857?utm_campaign=maleskine&utm_content=note&utm_medium=seo_notes&utm_source=recommendation

打开断点和启动监听

3.访问项目域名,就可以在phpstorm中看到变量信息,点击红框,可以查看每次执行的代码行,也会看到因为执行代码行所赋值的变量。

e4703199b857?utm_campaign=maleskine&utm_content=note&utm_medium=seo_notes&utm_source=recommendation

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

e4703199b857?utm_campaign=maleskine&utm_content=note&utm_medium=seo_notes&utm_source=recommendation

参考

https://www.jetbrains.com/help/phpstorm/2016.2/configuring-xdebug.html

http://stackoverflow.com/questions/36001918/phpstorm-xdebug-remote-host-is-configured-as-localhost-despite-server-host

转自:https://www.funboxpower.com/mac_php_xdebug_phpstorm_install

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值