Mac+ phpstorm 安装xdebug流程注意问题

本文详细介绍了在MacOS环境下安装Xdebug扩展的过程,包括解决常见错误如phpize安装失败、权限问题及如何配置php.ini使Xdebug生效。

第一步:进入“https://xdebug.org/wizard.php”,测试你的环境应该下载什么版本的xdebug

   进入网址后复制粘贴。phpinf()内的所有内容:

 

粘贴后,点击analyse my phpinfo()output

其中第4步注意,要把整体复制到你的php文件目录中,我的是在“/usr/local/Cellar/xdebug-2.7.2”

在此文件中cd /xdebug-2.7.2

第2步中要求安装"autoconf","automake"。最简单的方法是先安装一个“homebrew",然后在终端中运行:brew install autoconf 和 brew install automake 方法快速。

第5步运行phpize 时会出现

异常

grep: /usr/include/php/main/php.h: No such file or directory
grep: /usr/include/php/Zend/zend_modules.h: No such file or directory
grep: /usr/include/php/Zend/zend_extensions.h: No such file or directory
Configuring for:
PHP Api Version:
Zend Module Api No:
Zend Extension Api No:

场景

mac下,执行 phpize 安装PHP扩展时报错

解决

依次执行下面两条命令, 安装header包

cd /Library/Developer/CommandLineTools/Packages/
// 不同的mac系统, 可能名字不一样
open macOS_SDK_headers_for_macOS_10.14.pkg

安上面方法解决就可以了

到了第8步时,又出现问题。没有权限进行复制。(最好使用macos自带的xdebug.so,它同时也是在这个要复制到的目录里)

此时使用系统自带的xdebug.so。由于macos安全机制,即使复制过去,也没有办法使用。

https://jimfrenette.com/2018/12/xdebug-for-mac-os-x-php/

解决方法是:重启电脑按住command+R进行恢复模式。

输入:csrutil disable 禁止此特性。就可以进行cp。(使用完后如果要恢复此功能“csrutil enable,将会导致系统无法访问xdebug.so)”

第9步使用终端vi 进行编辑。

内容还加入以下内容:

xdebug.remote_enable = 1
xdebug.remote_autostart = 1
xdebug.idekey = PHPSTORM
xdebug.remote_handler = dbgp
xdebug.remote_host= localhost
xdebug.remote_connect_back = 1
xdebug.remote_port = 9000
xdebug.scream = 0
xdebug.show_local_vars = 1

进行完第10步就可以了 sudo su apachectl restart

成功后如下图:

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值