簡體   English   中英

OS X 10.9 Mavericks上的PHP Xdebug

[英]PHP Xdebug on OS X 10.9 Mavericks

在安裝OS X 10.9 Mavericks后,我在OS X上設置PHP開發環境時遇到問題。

這是我用來安裝的命令。

sudo pecl install xdebug

downloading xdebug-2.2.3.tgz ...
Starting to download xdebug-2.2.3.tgz (250,543 bytes)
.....................................................done: 250,543 bytes
66 source files, building
running: phpize
grep: /usr/include/php/main/php.h: No such file or directory
grep: /usr/include/php/Zend/zend_modules.h: No such file or directory
grep: /usr/include/php/Zend/zend_extensions.h: No such file or directory
Configuring for:
PHP Api Version:
Zend Module Api No:
Zend Extension Api No:
Cannot find autoconf. Please check your autoconf installation and the
$PHP_AUTOCONF environment variable. Then, rerun this script.

ERROR: `phpize' failed

任何人都有解決方案或解決方法?

快速復制粘貼方式

sudo sh -c 'echo zend_extension=$(find /usr/lib/php/extensions -name "xdebug.so") >> $(php -qr "echo php_ini_loaded_file();") && apachectl restart'

此命令執行以下操作:

  • 查找Xcode附帶的本機Xdebug擴展
  • 詢問php加載了哪個配置文件
  • 在配置文件中添加Xdebug擴展路徑
  • 重新啟動apache。

與Sierra,El Capitan和Yosemite兼容,帶有Bunleled apache,但未經MAMP和XAMPP測試。

在啟動命令之前,請確保已安裝Xcode命令行工具: xcode-select --install

不知道使用pecl 在沒有pecl情況下,在安裝OS X之后獲取Xdebug非常簡單。 你有兩個簡單的選擇:

  1. 使用以下版本:

     /usr/lib/php/extensions/no-debug-non-zts-2010052/xdebug.so 
  2. 建立你自己的:

    1. 確保您擁有Xcode CLI工具: xcode-select --install將提示您安裝CLI工具。 安裝CLI工具后, /usr/include/php應該有東西。

    2. 轉到http://xdebug.org/download.php並下載您想要的Xdebug版本的源代碼tarball。 例如: http//xdebug.org/files/xdebug-2.2.3.tgz

    3. 將tarball解壓縮並cd到它創建的目錄中。 在該目錄中,您將看到README 從這里開始:

       $ phpize Configuring for: PHP Api Version: 20100412 Zend Module Api No: 20100525 Zend Extension Api No: 220100525 $ ./configure --enable-xdebug checking for grep that handles long lines and -e... /usr/bin/grep checking for egrep... /usr/bin/grep -E checking for a sed that does not truncate output... /usr/bin/sed [... output ...] $ make [... output ...] 

您構建的xdebug.so現在位於modules/xdebug.so phpize對於安裝XCode CLI工具至關重要,因為phpize為您的PHP版本設置構建參數。

使用上面(1)或(2)中的xdebug.so ,您可以將此塊添加到phpphp-fpm使用的php.ini中:

[Xdebug]
zend_extension=<full_path_to_xdebug.so>
xdebug.remote_enable=1
xdebug.remote_host=<host running PHP (e.g. localhost)>
xdebug.remote_port=<port Xdebug tries to connect to on the host running PHP (default 9000)>

這里有兩個問題。 首先,您需要使用以下命令安裝Xcode命令行工具:

xcode-select --install

這意味着以前在/usr/include/php/找不到的文件將可用。

下一步是按照Ares在答案中顯示的方式安裝autoconf

我會cd到您的下載文件夾第一

cd ~/Downloads/
curl -OL http://ftpmirror.gnu.org/autoconf/autoconf-latest.tar.gz
tar xzf autoconf-latest.tar.gz
cd autoconf-*
./configure --prefix=/usr/local
make
sudo make install

現在你可以運行pecl install命令了

sudo pecl install xdebug

如果您使用的是Mac Yosemite 10.10,則上述答案均未解決問題。 請執行下列操作:

  1. 打開一個終端

  2. 執行find /usr/lib/php/extensions -name "xdebug.so"以了解調試庫的路徑。

  3. 執行sudo nano /etc/php.ini來打開並編輯php.ini文件
  4. 在php.ini中,最后添加以下行

     [XDebug] zend_extension="/usr/lib/php/extensions/no-debug-non-zts-20121212/xdebug.so" xdebug.remote_enable=1 xdebug.remote_handler=dbgp xdebug.remote_mode=req xdebug.remote_host=127.0.0.1 xdebug.remote_port=9000 

(完成后,鍵入control+o保存並control+x關閉文件)

(不要忘記在第一個終端命令中獲取的內容中替換zend_extension中的值)

  1. 執行sudo apachectl restart以加載新配置
  2. 高枕無憂

對於任何面臨此問題的人,我必須從源代碼構建autoconf。 我從另一個StackOverflow問題中聽到了這個答案。

https://stackoverflow.com/a/12333230/2272004

對於問題phpize錯誤,嘗試這將解決您的問題:sudo ln -s /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include / usr /包括

我不得不brew install xdebug並選擇我的PHP版本,它的工作brew install xdebug 例如,

brew install homebrew/php/php56-xdebug

對於PHP版本5.6變體。

暫無
暫無

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

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