Mac Phpstorm IDE 配置 Xdebug

本文详细介绍了在Mac环境下,如何在Phpstorm IDE中配置调试工具Xdebug。首先,通过Xdebug官网获取适合的扩展版本。接着,根据网站指示进行安装,解决phpize权限问题和/usr目录权限问题。最后,重启apache服务器和Webstorm,完成CLI Interpreter的配置,确保Xdebug正确工作。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Mac Phpstorm IDE 配置 Xdebug

在PhpStorm IDE中配置调试工具XDebug

1. 下载PHP扩展Xdebug

  1. 打开https://xdebug.org/wizard.php
  2. 在终端输入php -i,并复制自己的phpinfo(即输出的所有内容)粘贴到上述网页中,网站会自动生成需要下载的版本, 以及相应操作指导

2. 根据网站Instruction中所列内容操作

以我操作时的步骤为例

网站内容:

Instructions

1. Download xdebug-2.5.1.tgz
2. Unpack the downloaded file with tar -xvzf xdebug-2.5.1.tgz
3. Run: cd xdebug-2.5.1
4. Run: phpize (See the FAQ if you don't have phpize.

    As part of its output it should show:

    Configuring for:
    ...
    Zend Module Api No:      20121212
    Zend Extension Api No:   220121212
    If it does not, you are using the wrong phpize. Please follow this FAQ entry and skip the next step.

5. Run: ./configure
6. Run: make
7. Run: cp modules/xdebug.so /usr/lib/php/extensions/no-debug-non-zts-20121212
8. Create /etc/php.ini and add the line
zend_extension = /usr/lib/php/extensions/no-debug-non-zts-20121212/xdebug.so

可能遇到的问题:

a. phpize输出以下内容,最后提示Cannot find autoconf
Configuring for:
PHP Api Version:         20121113
Zend Module Api No:      20121212
Zend Extension Api No:   220121212
Cannot find autoconf. Please check your autoconf installation and the
$PHP_AUTOCONF environment variable. Then, rerun this script.

解决方案:输入命令 brew install autoconf,使用brew来下载autoconf

b. 第8步copy至usr中时发现没有权限

这是因为由于对Mac OS X 10.11 El Capitan用户,由于系统启用了SIP(System Integrity Protection), 导致root用户也没有权限修改/usr/bin目录

屏蔽方法:重启Mac,按住command+R,进入recovery模式。选择打开Utilities下的终端,
输入:csrutil disable并回车,然后正常重启Mac即可。

所有操作完毕后记得复原更改。

3. 重启apache服务器 & Webstorm

终端运行 apachectl restart

重启Webstorm,打开 Default Preferences -> Languages&Frameworks -> PHP,
点击下图红框中的按钮,添加CLI Interpreter的信息

Webstorm xdebug配置

在Debugger extension中输入刚刚copy到/usr/lib/php/extensions/…目录中的xdebug.so文件,点击OK,大功告成!

Webstorm xdebug配置



配置过程中如仍有问题欢迎留言交流~

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值