簡體   English   中英

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

[英]Can't get Xdebug to work in PHPStorm with PHP & XAMPP on Mac OS

我一直在努力在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”行中,並且不知道如何從此處繼續。

很抱歉,這已經很長時間了,但是我想詳細介紹到目前為止我已經嘗試過的工作,並希望能幫助其他可能嘗試相同操作的人。

事實證明,@漢尼拔回答了這個問題的較不詳細的版本。 我決定將這個問題留在這里,因為我詳細介紹了如何為運行的命令定位直線路徑。

./configure無法正常工作的原因是xdebug-2.6.1發行版中的一個錯誤。 @Hannibal指出xdebug-2.7.0beta1修復了此錯誤。 因此,使用Beta版本可以使用簡單的向導說明。 我現在有xdebug在PHPStorm中工作。

這里是一個問題的鏈接,該問題不必處理多個版本的PHP和Apache,而僅涉及Mac OSX上的XAMPP和xdebug。 較簡單的問題

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM