安装之前先确保你安装过homebrew,如果没有,请在这里安装:https://brew.sh/
接下来进行下载安装xdebug:
1、查看你的PHP版本:php -v
2、找到与你PHP版本匹配的xdebug : brew search xdebug

3、下载对应的xdebug:

4、安装完成后,找到xdebug.so文件所在位置: /usr/local/Cellar/php71-xdebug/2.5.5/xdebug.so(下一步要用到)
5、找到PHP配置文件:(这里并不是在php.ini里配置)
/usr/local/etc/php/7.1/conf.d/ext-xdebug.ini
进去添加如下(注意这里填的是你电脑里xdebug.so的路径,由于9000端口容易被占用,所以我用的9001)

6、重启PHP:(这里不要用sudo)

这时候你可以在项目index.php里打印一下phpinfo(),可以看到(记住IDE Key,一会儿要用)

xdebug就安装完成了,我们去phpstorm里配置一下
1、打开phpstorm的偏好设置,如图设置
记住你的PHP版本一定要选对


这里的IDE Key就是刚才PHPinfo里的IDE Key

这里的名字可以自己设置,用于区分哪个项目,host填写的是这个项目的域名,每个项目的server都不一样

然后进入PHPstorm右上角,点击edit

点击加号创建,server是刚才创建的server,url是这个项目调试的网址。带http://

2、.env文件的debug都设置为true
APP_DEBUG=true
APP_LOG_LEVEL=debug
DEBUGBAR_ENABLED=true
现在试着打个断点,调试一下吧,嘻嘻
网友评论