未定义的符号:zend_type_to_string

Undefined symbol: zend_type_to_string

我对 ArchLinux 有点陌生,但我已经用 pacman 安装了 PHP 7,然后安装了 Xdebug,但 Xdebug 安装了 php 包(即 PHP 8 )。

当我尝试启动 PHP 7 时,我收到以下消息并且 Xdebug 不工作:

PHP Warning: Failed loading Zend extension 'xdebug.so' (tried: /usr/lib/php7/modules/xdebug.so (/usr/lib/php7/modules/xdebug.so: undefined symbol: zend_type_to_string), /usr/lib/php7/modules/xdebug.so.so (/usr/lib/php7/modules/xdebug.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0

那是我的 /etc/php7/conf.d/xdebug.ini

zend_extension=xdebug.so
;xdebug.remote_enable=on
;xdebug.remote_host=127.0.0.1
;xdebug.remote_port=9000
;xdebug.remote_handler=dbgp
;xdebug.start_with_request=yes
;xdebug.mode=debug

所以如果有人有解决方案:)

我遇到了同样的问题。

所以,我卸载了 PHP 8 并为 PHP 7.4 安装了 Xdebug:

yay -S xdebug7

我找到了解决方案 here !

$ asp update xdebug
$ asp export xdebug

之后我更新了 PKGBUILD

$ cat PKGBUILD 
--------------------------------------------------------------------
# Maintainer: Sergej Pupykin <pupykin.s+arch@gmail.com>
# Maintainer: Jonathan Wiersma <arch aur at jonw dot org>
# Contributor: Jonathan Wiersma <arch aur at jonw dot org>
# Contributor: sracker <smb.sac@gmail.com>

pkgname=xdebug-php7
pkgver=3.0.2
pkgrel=2
pkgdesc="PHP debugging extension for php7"
arch=('x86_64')
url="https://www.xdebug.org"
license=('GPL')
depends=('php7')
backup=('etc/php/conf.d/xdebug.ini')
source=("https://xdebug.org/files/xdebug-${pkgver}.tgz"
    'xdebug.ini')
sha256sums=('096d46dec061341868d3e3933b977013a592e2e88992b2c0aba7fa52f87c4e17'
            '7c66883dc2ade69069ef84e30188b25630748aa9c8b0dd123727c00505421205')

build() {
  cd "$srcdir"/xdebug-${pkgver}
  phpize7
  ./configure --prefix=/usr --enable-xdebug
  make
}

package() {
  cd "$srcdir"/xdebug-${pkgver}
  make INSTALL_ROOT="$pkgdir" install
  install -D -m 644 "$srcdir"/xdebug.ini "$pkgdir"/etc/php7/conf.d/xdebug.ini
}
--------------------------------------------------------------

然后我就这么做了 makepkg -s -i -r