Mac Phpstorm IDE 配置 Xdebug

Mac Phpstorm IDE 配置 Xdebug

在PhpStorm IDE中配置调试工具XDebug

  • Mac Phpstorm IDE 配置 Xdebug
    • 下载PHP扩展Xdebug
    • 根据网站Instruction中所列内容操作
      • 可能遇到的问题
        • a phpize输出以下内容最后提示Cannot find autoconf
        • b 第8步copy至usr中时发现没有权限
    • 重启apache服务器 Webstorm

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的信息

Mac Phpstorm IDE 配置 Xdebug_第1张图片

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

Mac Phpstorm IDE 配置 Xdebug_第2张图片



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

你可能感兴趣的:(PHP)