简体   繁体   English

在 Mac 上使用 XAMPP 安装 XDebug for PHP

[英]Installing XDebug for PHP with XAMPP on Mac

I have a Mac with a fresh OSX Mojave install.我有一台安装了全新 OSX Mojave 的 Mac。 I downloaded XAMPP (7.3) and installed.我下载了 XAMPP (7.3) 并安装了。 The local Apache web server works and the PHPInfo() I get from the dashboard shows all the correct information for the php.ini file being the /Applications/XAMPP/xamppfiles/etc/php.ini.本地 Apache Web 服务器正常工作,我从仪表板获得的 PHPInfo() 显示了 php.ini 文件的所有正确信息,即 /Applications/XAMPP/xamppfiles/etc/php.ini。

I have taken a copy of the PHPInfo and put it in the wizard at:我已经复制了 PHPInfo 并将其放在向导中:

https://xdebug.org/wizard.php https://xdebug.org/wizard.php

The instructions look simple.说明看起来很简单。 I did have to use homebrew to install autoconf first.我确实必须先使用自制软件来安装 autoconf。

But then I was able to download and unpack the xdebug-2.6.1.tgz in the /Applications/XAMPP/xamppfiles/ folder.但是后来我能够在 /Applications/XAMPP/xamppfiles/ 文件夹中下载并解压 xdebug-2.6.1.tgz。

I changed my $PATH variable to have /Applications/XAMPP/xamppfiles/bin be the first path searched, so that the correct phpize would run.我改变了我的 $PATH 变量,让 /Applications/XAMPP/xamppfiles/bin 成为搜索的第一个路径,这样正确的 phpize 就会运行。

I changed to the /Applications/XAMPP/xamppfiles/xdebug-2.6.1 folder and ran phpize, then I ran ./configure.我更改为 /Applications/XAMPP/xamppfiles/xdebug-2.6.1 文件夹并运行 phpize,然后运行 ​​./configure。 Everything seemed to run well with no perceived errors.一切似乎运行良好,没有明显的错误。

But then I got errors when I ran the "make" command.但是当我运行“make”命令时出现错误。 Here is the output I got:这是我得到的输出:

> 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

So the first error I see in the "make" command is "> error: too few arguments to function call, expected 6, have 5".所以我在“make”命令中看到的第一个错误是“>”错误:函数调用的参数太少,预期为 6,有 5”。

I have no idea where to go from here.我不知道从这里去哪里。 The endless documents I've read either seem to be for PC or for PHP 5.我读过的无穷无尽的文档似乎适用于 PC 或 PHP 5。

There is a bug for this.这有一个错误。 The link is thus: https://bugs.xdebug.org/view.php?id=1593链接是这样的: https : //bugs.xdebug.org/view.php?id=1593

Which describes that you need to use Xdebug 2.7.0beta1 for now.其中描述您现在需要使用 Xdebug 2.7.0beta1。

Hannibal is correct, but his answer is a bit terse so I want to expand on it a bit.汉尼拔是对的,但他的回答有点简洁,所以我想稍微扩展一下。

This is a XDebug bug for PHP 7.3.x so you'll need to install XDebug 2.7.0beta1:这是 PHP 7.3.x 的 XDebug 错误,因此您需要安装 XDebug 2.7.0beta1:

$ pecl install xdebug-2.7.0beta1

Since I installed the latest PHP version using Homebrew, the XDebug installation actually threw two mkdir() errors.由于我使用 Homebrew 安装了最新的 PHP 版本,因此 XDebug 安装实际上抛出了两个mkdir()错误。 This was because there was already a pecl symlink in Homebrew's PHP directory.这是因为 Homebrew 的 PHP 目录中已经有一个pecl符号链接。

First I wanted to verify that, so I ran $ ls -al /usr/local/Cellar/php/<YOUR_PHP_VERSION_NUMBER>首先我想验证一下,所以我运行了$ ls -al /usr/local/Cellar/php/<YOUR_PHP_VERSION_NUMBER>

If you have any doubt about your PHP version, it should be in the pecl installation log and listed right alongside the mkdir() errors.如果您对您的 PHP 版本有任何疑问,它应该在pecl安装日志中并列在mkdir()错误旁边。

Once I confirmed that there was already a symlink there, I simply removed it:一旦我确认那里已经有一个符号链接,我就把它删除了:

$ rm /usr/local/Cellar/php/<YOUR_PHP_VERSION_NUMBER>/pecl

After I did that, I ran the install again and it worked smoothly.在我这样做之后,我再次运行安装并且运行顺利。

Of course, $ php --ini showed errors, so I had to configure PHP properly.当然, $ php --ini显示错误,所以我必须正确配置PHP。 Gabor Javorsky actually wrote a great article which includes how to ensure XDebug gets loaded correctly and it worked perfectly for me. Gabor Javorsky 实际上写了一篇很棒的文章,其中包括如何确保正确加载 XDebug 并且它对我来说完美无缺。 See Step 2 in his article here: https://javorszky.co.uk/2018/05/03/getting-xdebug-working-on-php-7-2-and-homebrew/ .请参阅他的文章中的第 2 步https : //javorszky.co.uk/2018/05/03/getting-xdebug-working-on-php-7-2-and-homebrew/

Don't forget to reload PHP after tweaking your config, which for me was:不要忘记在调整配置后重新加载 PHP,对我来说是:

$ brew services stop php@7.2 && brew services start php@7.2

After that, $ php --ini should show no errors!之后, $ php --ini应该不会显示任何错误!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM