mac下phpstorm配置xdebug

mac下phpstorm配置xdebug

准备工作

  • 你有phpstrom,同时安装了homebrew

开始工作

习惯了用echo和var_dump(),但是每一次都需要去查找是哪个部分出了错误,这样你就要去写好多的echo或者var_dump去定位到底是哪里出了错误,同时,我们用的是phpstorm IDE啊这样的编辑器必要要好好利用下了

1、安装xdebug

1
2
这个应该简单了
brew install xdebug //根据你自己的php版本进行选择xdebug的版本

2、配置xdebug
因为是用brew安装的所以这个文件是在 /usr/local/etc/php/5.6/conf.d目录中ext-xdebug.ini

1
2
3
4
5
6
7
8
xdebug.remote_enable = On
xdebug.remote_handler = dbgp
xdebug.remote_host= localhost
xdebug.idekey = PHPSTORM
xdebug.remote_autostart=1 //主要 这个一定要配置,
xdebug.remote_enable=1
xdebug.remote_mode="req"
xdebug.remote_port=9001 //这个是在phpstorm中配置debug端口和http代理端口

3、配置phpstorm

  • 进入File>Settings>PHP>Debug,看到XDebug选项卡,port填9001,其他默认
  • 进入File>Settings>PHP>Servers,host 填localhost,port 填80
  • 进入File>Settings>PHP>Debug>DBGp Proxy,IDE key 填 PHPSTORM,host 填localhost,port 填80

4、下面就可以进行测试了哦,在phpstorm的右上角有个debug的配置,然后填写你要启动的页面就可以了

总结

good luck