在 Mac 上使用 XAMPP 为 PHP 安装 XDebug
Installing XDebug for PHP with XAMPP on Mac
我有一个 Mac 全新 OSX Mojave 安装。我下载了 XAMPP (7.3) 并安装了。本地 Apache Web 服务器正常工作,我从仪表板获得的 PHPInfo() 显示 php.ini 文件的所有正确信息是 /Applications/XAMPP/xamppfiles/etc/php.ini。
我已经复制了一份 PHPInfo 并将其放入向导中:
说明看起来很简单。我确实必须先使用自制软件来安装 autoconf。
但后来我能够下载并解压 xdebug-2.6。1.tgz 在 /Applications/XAMPP/xamppfiles/ 文件夹中。
我更改了我的 $PATH 变量,使 /Applications/XAMPP/xamppfiles/bin 成为第一个搜索路径,这样正确的 phpize 就会 运行.
我更改到 /Applications/XAMPP/xamppfiles/xdebug-2.6.1 文件夹和 运行 phpize,然后我 运行 ./configure。一切似乎 运行 都很好,没有发现任何错误。
但是当我 运行 "make" 命令时出现错误。这是我得到的输出:
> Terrys-MacBook-Pro:xdebug-2.6.1 terry$ make /bin/sh
> /Applications/XAMPP/xamppfiles/xdebug-2.6.1/libtool --mode=compile cc
> -I. -I/Applications/XAMPP/xamppfiles/xdebug-2.6.1 -DPHP_ATOM_INC -I/Applications/XAMPP/xamppfiles/xdebug-2.6.1/include -I/Applications/XAMPP/xamppfiles/xdebug-2.6.1/main -I/Applications/XAMPP/xamppfiles/xdebug-2.6.1 -I/Applications/XAMPP/xamppfiles/include/php -I/Applications/XAMPP/xamppfiles/include/php/main -I/Applications/XAMPP/xamppfiles/include/php/TSRM -I/Applications/XAMPP/xamppfiles/include/php/Zend -I/Applications/XAMPP/xamppfiles/include/php/ext -I/Applications/XAMPP/xamppfiles/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -c /Applications/XAMPP/xamppfiles/xdebug-2.6.1/xdebug_compat.c -o
> xdebug_compat.lo cc -I.
> -I/Applications/XAMPP/xamppfiles/xdebug-2.6.1 -DPHP_ATOM_INC -I/Applications/XAMPP/xamppfiles/xdebug-2.6.1/include -I/Applications/XAMPP/xamppfiles/xdebug-2.6.1/main -I/Applications/XAMPP/xamppfiles/xdebug-2.6.1 -I/Applications/XAMPP/xamppfiles/include/php -I/Applications/XAMPP/xamppfiles/include/php/main -I/Applications/XAMPP/xamppfiles/include/php/TSRM -I/Applications/XAMPP/xamppfiles/include/php/Zend -I/Applications/XAMPP/xamppfiles/include/php/ext -I/Applications/XAMPP/xamppfiles/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -c /Applications/XAMPP/xamppfiles/xdebug-2.6.1/xdebug_compat.c
> -fno-common -DPIC -o .libs/xdebug_compat.o /Applications/XAMPP/xamppfiles/xdebug-2.6.1/xdebug_compat.c:56:71:
**> error: too few arguments to function call, expected 6, have 5**
> return zend_get_zval_ptr(op_type, node, zdata, &should_free, BP_VAR_R);
> ~~~~~~~~~~~~~~~~~ ^
> /Applications/XAMPP/xamppfiles/include/php/Zend/zend_execute.h:330:1:
> note: 'zend_get_zval_ptr' declared here ZEND_API zval
> *zend_get_zval_ptr(const zend_op *opline, int op_type, const znode_op *node, const zend_execute_data *execute_data, zend_free_op *should_free, int type); ^ /Applications/XAMPP/xamppfiles/include/php/main/php_config.h:9:19:
> note: expanded from macro 'ZEND_API'
> # define ZEND_API __attribute__ ((visibility("default")))
> ^ /Applications/XAMPP/xamppfiles/xdebug-2.6.1/xdebug_compat.c:194:88:
> error: too few arguments to function call, expected 9, have 8
> php_setcookie(name_s, value_s, expires, path_s, domain_s, secure, url_encode, httponly);
> ~~~~~~~~~~~~~ ^ /Applications/XAMPP/xamppfiles/include/php/ext/standard/head.h:40:1:
> note: 'php_setcookie' declared here PHPAPI int
> php_setcookie(zend_string *name, zend_string *value, time_t expires,
> zend_string *path, zend_string *domain, int secure, int httponly,
> zend_string *samesite, int url_encode); ^
> /Applications/XAMPP/xamppfiles/include/php/main/php.h:72:18: note:
> expanded from macro 'PHPAPI'
> # define PHPAPI __attribute__ ((visibility("default")))
> ^ 2 errors generated. make: *** [xdebug_compat.lo] Error 1
所以我在 "make" 命令中看到的第一个错误是“> 错误:函数调用的参数太少,预期 6 个,有 5 个”。
我不知道从这里到哪里去。我读过的无穷无尽的文档似乎是针对 PC 或 PHP 5.
这有一个错误。因此 link 是:https://bugs.xdebug.org/view.php?id=1593
这说明您现在需要使用 Xdebug 2.7.0beta1。
Hannibal 是正确的,但他的回答有点简洁,所以我想扩展一下。
这是 PHP 7 的 XDebug 错误。3.x 因此您需要安装 XDebug 2.7.0beta1:
$ pecl install xdebug-2.7.0beta1
由于我使用 Homebrew 安装了最新的 PHP 版本,XDebug 安装实际上抛出了两个 mkdir()
错误。这是因为 Homebrew 的 PHP 目录中已经有一个 pecl
符号链接。
首先我想验证一下,所以我运行$ ls -al /usr/local/Cellar/php/<YOUR_PHP_VERSION_NUMBER>
如果您对 PHP 版本有任何疑问,它应该在 pecl
安装日志中并列在 mkdir()
错误旁边。
一旦我确认那里已经有一个符号链接,我就将其删除:
$ rm /usr/local/Cellar/php/<YOUR_PHP_VERSION_NUMBER>/pecl
在我这样做之后,我 运行 再次安装并且运行顺利。
当然,$ php --ini
显示错误,所以我必须正确配置PHP。 Gabor Javorsky 实际上写了一篇很棒的文章,其中包括如何确保 XDebug 被正确加载并且它对我来说非常有效。 参见他文章中的步骤 2:https://javorszky.co.uk/2018/05/03/getting-xdebug-working-on-php-7-2-and-homebrew/。
不要忘记在调整配置后重新加载 PHP,这对我来说是:
$ brew services stop php@7.2 && brew services start php@7.2
之后,$ php --ini
应该不会显示任何错误!
我有一个 Mac 全新 OSX Mojave 安装。我下载了 XAMPP (7.3) 并安装了。本地 Apache Web 服务器正常工作,我从仪表板获得的 PHPInfo() 显示 php.ini 文件的所有正确信息是 /Applications/XAMPP/xamppfiles/etc/php.ini。
我已经复制了一份 PHPInfo 并将其放入向导中:
说明看起来很简单。我确实必须先使用自制软件来安装 autoconf。
但后来我能够下载并解压 xdebug-2.6。1.tgz 在 /Applications/XAMPP/xamppfiles/ 文件夹中。
我更改了我的 $PATH 变量,使 /Applications/XAMPP/xamppfiles/bin 成为第一个搜索路径,这样正确的 phpize 就会 运行.
我更改到 /Applications/XAMPP/xamppfiles/xdebug-2.6.1 文件夹和 运行 phpize,然后我 运行 ./configure。一切似乎 运行 都很好,没有发现任何错误。
但是当我 运行 "make" 命令时出现错误。这是我得到的输出:
> Terrys-MacBook-Pro:xdebug-2.6.1 terry$ make /bin/sh
> /Applications/XAMPP/xamppfiles/xdebug-2.6.1/libtool --mode=compile cc
> -I. -I/Applications/XAMPP/xamppfiles/xdebug-2.6.1 -DPHP_ATOM_INC -I/Applications/XAMPP/xamppfiles/xdebug-2.6.1/include -I/Applications/XAMPP/xamppfiles/xdebug-2.6.1/main -I/Applications/XAMPP/xamppfiles/xdebug-2.6.1 -I/Applications/XAMPP/xamppfiles/include/php -I/Applications/XAMPP/xamppfiles/include/php/main -I/Applications/XAMPP/xamppfiles/include/php/TSRM -I/Applications/XAMPP/xamppfiles/include/php/Zend -I/Applications/XAMPP/xamppfiles/include/php/ext -I/Applications/XAMPP/xamppfiles/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -c /Applications/XAMPP/xamppfiles/xdebug-2.6.1/xdebug_compat.c -o
> xdebug_compat.lo cc -I.
> -I/Applications/XAMPP/xamppfiles/xdebug-2.6.1 -DPHP_ATOM_INC -I/Applications/XAMPP/xamppfiles/xdebug-2.6.1/include -I/Applications/XAMPP/xamppfiles/xdebug-2.6.1/main -I/Applications/XAMPP/xamppfiles/xdebug-2.6.1 -I/Applications/XAMPP/xamppfiles/include/php -I/Applications/XAMPP/xamppfiles/include/php/main -I/Applications/XAMPP/xamppfiles/include/php/TSRM -I/Applications/XAMPP/xamppfiles/include/php/Zend -I/Applications/XAMPP/xamppfiles/include/php/ext -I/Applications/XAMPP/xamppfiles/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -c /Applications/XAMPP/xamppfiles/xdebug-2.6.1/xdebug_compat.c
> -fno-common -DPIC -o .libs/xdebug_compat.o /Applications/XAMPP/xamppfiles/xdebug-2.6.1/xdebug_compat.c:56:71:
**> error: too few arguments to function call, expected 6, have 5**
> return zend_get_zval_ptr(op_type, node, zdata, &should_free, BP_VAR_R);
> ~~~~~~~~~~~~~~~~~ ^
> /Applications/XAMPP/xamppfiles/include/php/Zend/zend_execute.h:330:1:
> note: 'zend_get_zval_ptr' declared here ZEND_API zval
> *zend_get_zval_ptr(const zend_op *opline, int op_type, const znode_op *node, const zend_execute_data *execute_data, zend_free_op *should_free, int type); ^ /Applications/XAMPP/xamppfiles/include/php/main/php_config.h:9:19:
> note: expanded from macro 'ZEND_API'
> # define ZEND_API __attribute__ ((visibility("default")))
> ^ /Applications/XAMPP/xamppfiles/xdebug-2.6.1/xdebug_compat.c:194:88:
> error: too few arguments to function call, expected 9, have 8
> php_setcookie(name_s, value_s, expires, path_s, domain_s, secure, url_encode, httponly);
> ~~~~~~~~~~~~~ ^ /Applications/XAMPP/xamppfiles/include/php/ext/standard/head.h:40:1:
> note: 'php_setcookie' declared here PHPAPI int
> php_setcookie(zend_string *name, zend_string *value, time_t expires,
> zend_string *path, zend_string *domain, int secure, int httponly,
> zend_string *samesite, int url_encode); ^
> /Applications/XAMPP/xamppfiles/include/php/main/php.h:72:18: note:
> expanded from macro 'PHPAPI'
> # define PHPAPI __attribute__ ((visibility("default")))
> ^ 2 errors generated. make: *** [xdebug_compat.lo] Error 1
所以我在 "make" 命令中看到的第一个错误是“> 错误:函数调用的参数太少,预期 6 个,有 5 个”。
我不知道从这里到哪里去。我读过的无穷无尽的文档似乎是针对 PC 或 PHP 5.
这有一个错误。因此 link 是:https://bugs.xdebug.org/view.php?id=1593
这说明您现在需要使用 Xdebug 2.7.0beta1。
Hannibal 是正确的,但他的回答有点简洁,所以我想扩展一下。
这是 PHP 7 的 XDebug 错误。3.x 因此您需要安装 XDebug 2.7.0beta1:
$ pecl install xdebug-2.7.0beta1
由于我使用 Homebrew 安装了最新的 PHP 版本,XDebug 安装实际上抛出了两个 mkdir()
错误。这是因为 Homebrew 的 PHP 目录中已经有一个 pecl
符号链接。
首先我想验证一下,所以我运行$ ls -al /usr/local/Cellar/php/<YOUR_PHP_VERSION_NUMBER>
如果您对 PHP 版本有任何疑问,它应该在 pecl
安装日志中并列在 mkdir()
错误旁边。
一旦我确认那里已经有一个符号链接,我就将其删除:
$ rm /usr/local/Cellar/php/<YOUR_PHP_VERSION_NUMBER>/pecl
在我这样做之后,我 运行 再次安装并且运行顺利。
当然,$ php --ini
显示错误,所以我必须正确配置PHP。 Gabor Javorsky 实际上写了一篇很棒的文章,其中包括如何确保 XDebug 被正确加载并且它对我来说非常有效。 参见他文章中的步骤 2:https://javorszky.co.uk/2018/05/03/getting-xdebug-working-on-php-7-2-and-homebrew/。
不要忘记在调整配置后重新加载 PHP,这对我来说是:
$ brew services stop php@7.2 && brew services start php@7.2
之后,$ php --ini
应该不会显示任何错误!