无法加载 Xdebug,因为 PHP 是使用 API NTS 调试构建的

Cannot load Xdebug, as PHP was built with API NTS debug

我使用 brew 安装了 php70 和 php70-xdebug。

brew install php70
brew install php70-xdebug

php -v returns 这个错误:

Cannot load Xdebug - it was built with configuration API320151012,NTS, whereas running engine is API320151012,NTS,debug

我不知道如何将 --disable-debug 传递给编译器,brew 使用预配置公式 (https://github.com/Homebrew/homebrew-php),并且不允许设置此选项。

问题是:xdebug公式有--disable-debug,而php70公式有一个选项--with-debug,但即使你不使用这个参数,它也会附加--enable-debug 到配置命令。

我找到了一个解决方法,它并不完美,但它有效!

  1. 使用 brew edit php70-xdebug 编辑公式并将 --enable-debug 添加到配置命令:

    system "./configure", "--prefix=#{prefix}",
                      phpconfig,
                      "--disable-dependency-tracking",
                      "--enable-xdebug",
                      "--enable-debug"
    
  2. 重新编译库

    brew reinstall php70-xdebug --build-from-source
    

同样的事情也适用于 php70-opcache