使用 laravel 进行开发,可以通过使用 dd,dump 等方法进行调试,但是现在我想通过 xdebug 一步步调试,看看框架都做了什么流程,在此记录一下如何使用 phpstorm 开启 xdebug
安装 xdebug 扩展
一句话搞定安装扩展
pecl install xdebug
添加配置
[xdebug]
zend_extension="xdebug.so"
xdebug.remote_autostart=1
xdebug.default_enable=1
xdebug.remote_port=9001
xdebug.remote_host=127.0.0.1
xdebug.remote_connect_back=1
xdebug.remote_enable=1
xdebug.idekey=PHPSTORM
使用 phpinfo () 查看是否安装完成 xdebug 扩展,若出现以下内容,则说明成功安装 xdebug 扩展
并查看 xdebug.remote_enable, 确保为 on 开启
配置 phpstorm
我使用的 phpstorm 版本为 2019.3
点击 phpstorm 左上角 phpstorm>>Preferences
点击 Languages & Frameworks > PHP > Debug, 这里配置 Debug port 与我们配置的 xdebug.remote_port 对应,这里配置 9001
点击 Languages & Frameworks > PHP > Debug > DBGp Proxy, 配置本地信息
点击 Languages & Frameworks > PHP > Servers, 这里配置我们需要调试的域名,如下按照你的域名去配置即可
点击这里添加配置
点击添加 PHP Web Page
这里选择添加之前 Servers 添加的配置
配置完成后,就可以愉快的使用 phpstorm 进行 debug
————————————————
原文作者:oliver-l
转自链接:mac使用phpstorm开启xdebug | Laravel China 社区
版权声明:著作权归作者所有。商业转载请联系作者获得授权,非商业转载请保留以上作者信息和原文链接。