无法在Mac OS上使Xdebug与PHP和XAMPP一起在PHPStorm中工作

时间:2018-12-20 04:08:04

标签: php xampp phpstorm xdebug

我一直在努力在Mac上的PHPStorm中设置Xdebugger。这是我尝试过发现的摘要。任何帮助将非常感激。

经过很多挣扎和担心,我弄乱了东西,然后擦了擦Macbook,重新安装了MacOSX Mojave。我为Mac v7.3.0(PHP7.3.0)安装了XAMPP。安装XAMPP之后,我可以打开Chrome并转到localhost,然后看到正确的Apache站点,例如仪表板,phpmyadmin和phpinfo。我可以确认php信息显示v7.3。

在SO上有一篇帖子,其中有人安装了2个版本的php,所以我发现我确实(用新的OS安装)确实有2个版本的php。如果我从命令行执行php --version,我将获得v7.1。但是,如果我切换到XAMPP目录(/ Applications / XAMPP / xamppfiles / bin),则php --info将显示我的7.3版本。这告诉我在以后尝试安装Xdebug时参考命令时要格外小心。

我还安装了PHPStorm并设置了语言版本的PHP 7.3,指向XAMPP目录中的ini文件。一切在PHPStorm中都可以正常工作,因为我可以创建一个测试php文件并调用phpinfo()方法以显示7.3的正确php版本。但是在PHPStorm的php language部分中,调试器显示未安装它。

所以我认为我已经使用XAMPP和PHP 7.3正确设置了PHPStorm。

在整理不同的php版本时,我认为php 7.1位于路径环境中,这意味着如果要使用XAMPP文件夹中的php 7.3,则需要引用绝对位置。我运行了php --version和php --ini,它给出了以下输出:

Terrys-MBP:~ terry$ /Applications/XAMPP/xamppfiles/bin/php --version
PHP 7.3.0 (cli) (built: Dec 11 2018 01:01:47) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.0-dev, Copyright (c) 1998-2018 Zend Technologies
Terrys-MBP:~ terry$ 
Terrys-MBP:~ terry$ 
Terrys-MBP:~ terry$ /Applications/XAMPP/xamppfiles/bin/php --ini
Configuration File (php.ini) Path: /Applications/XAMPP/xamppfiles/etc
Loaded Configuration File:         
/Applications/XAMPP/xamppfiles/etc/php.ini
Scan for additional .ini files in: (none)
Additional .ini files parsed:      (none)
Terrys-MBP:~ terry$ 

因此,我将phpinfo输出复制到https://xdebug.org/wizard.php以获得安装Xdebug的自定义说明。这是输出和说明。 (很抱歉格式化)

Tailored Installation Instructions
Summary
Xdebug installed: no
Server API: Apache 2.0 Handler
Windows: no
Zend Server: no
PHP Version: 7.3.0
Zend API nr: 320180731
PHP API nr: 20180731
Debug Build: no
Thread Safe Build: no
Configuration File Path: /Applications/XAMPP/xamppfiles/etc
Configuration File: /Applications/XAMPP/xamppfiles/etc/php.ini
Extensions directory: 
/Applications/XAMPP/xamppfiles/lib/php/extensions/no-debug-non-zts- 
20180731

Instructions
Download xdebug-2.6.1.tgz
Unpack the downloaded file with tar -xvzf xdebug-2.6.1.tgz
Run: cd xdebug-2.6.1
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:      20180731
Zend Extension Api No:   320180731
If it does not, you are using the wrong phpize. Please follow this FAQ 
entry and skip the next step.

Run: ./configure
Run: make
Run: cp modules/xdebug.so 
/Applications/XAMPP/xamppfiles/lib/php/extensions/no-debug-non-zts- 
20180731
Edit /Applications/XAMPP/xamppfiles/etc/php.ini and add the line
zend_extension = /Applications/XAMPP/xamppfiles/lib/php/extensions/no- 
debug-non-zts-20180731/xdebug.so
Restart the webserver

所以,我遵循了泰勒指令。

我下载了xdebug-2.6.1.tgz并将其解压缩到/ Applications / XAMPP / xamppfiles /文件夹中,然后更改为xdebug-2.6.1文件夹。

运行phpize不能给我正确的输出,因此我单击了给定的链接https://xdebug.org/docs/faq#custom-phpize以查找要使用的phpize文件。所以我运行的phpize行是:

/Applications/XAMPP/xamppfiles/bin/phpize from the 
/Applications/XAMPP/xamppfiles/xdebug-2.6.1 folder

phpize提供了正确的输出,因此我继续执行./configure行:

./configure --with-php-config=/Applications/XAMPP/xamppfiles/bin/php-config

我相信第一次运行会让我从Homebrew下载的autoconf出现错误。下次运行时,我收到了有关配置文件“ .in”和“ .ac”的消息,我查找并重命名了“ .in”文件,因为该文件已被淘汰而支持“ .ac”文件。此时,。/ configure行已运行,没有任何明显的错误。

最后,我运行“ make”并得到以下类型的错误和警告:(很抱歉,关于行长的格式已关闭)

警告:

/Applications/XAMPP/xamppfiles/xdebug-2.6.1/xdebug.c:1831:107: warning: 
format
      specifies type 'long' but the argument has type 'zend_long'
      (aka 'long long') [-Wformat]
  ...nesting level of '%ld' reached, aborting!", 
  XG(max_nesting_level));
                   ~~~                       ^~~~~~~~~~~~~~~~~~~~~
                   %lld
./php_xdebug.h:323:15: note: expanded from macro 'XG'
#define XG(v) (xdebug_globals.v)
              ^~~~~~~~~~~~~~~~~~

/Applications/XAMPP/xamppfiles/xdebug- 
2.6.1/xdebug_code_coverage.c:624:17: warning: 
      implicit declaration of function 'RT_CONSTANT_EX' is invalid in 
C99
      [-Wimplicit-function-declaration]
                array_value = RT_CONSTANT_EX(opa->literals, 
opcode.op2);
                              ^

错误:(更多,但我只列出了第一个)

/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);
               ~~~~~~~~~~~~~~~~~    

所以现在我被困在“ make”行,不知道如何从这里继续。

很抱歉,这么长的时间,但是我想详细介绍到目前为止我已经尝试过的方法,并希望能帮助其他可能尝试相同步骤的人。

1 个答案:

答案 0 :(得分:0)

事实证明,@汉尼拔回答了这个问题的较不详细的版本。我决定将这个问题留在这里,因为我详细介绍了如何为运行的命令定位直线路径。

./ configure无法正常工作的原因是xdebug-2.6.1发行版中的错误。 @Hannibal指出xdebug-2.7.0beta1修复了此错误。因此,使用Beta版本可以使用简单的向导说明。我现在有xdebug在PHPStorm中工作。

这里是一个问题的链接,该问题不必处理多个版本的PHP和Apache,而仅需处理Mac OSX上的XAMPP和xdebug。 enter image description here