MAC 下 netbeans xdebug 調試PHP代碼_PHP教程

來源:互聯網
上載者:User
今天在MAC下,想調試PHP代碼,發現netbeans 掛不上斷點,根本調試不了。一番搜尋發現有個PHP的第三方模組叫xdebug ,雖然只找到一些windows 下的資料,但還是摸索著把調試環境搭建成功。

配置過程:

安裝xdebug

修改php.ini

重啟apache

確認netbeans 的調試連接埠與xdebug 一致

(1)下載xdebug

我這裡使用了brew, 如果對brew工具不熟悉的可以Google下。

首先習慣性搜尋下:

終端裡執行命令:brew search xdebug 發現的確有一個軟體xdebug。

然後 brew install xdebug ,一路順風順水 。安裝完畢有提示安裝的情況。

沒記住沒關係:brew info xdebug

[hechangmin@hecm-mac ~]$brew info xdebug

xdebug 2.1.2

http://xdebug.org

/usr/local/Cellar/xdebug/2.1.2 (348K)

To use this software:

* Add the following line to php.ini:

zend_extension="/usr/local/Cellar/xdebug/2.1.2/xdebug.so"

* Restart your webserver.

* Write a PHP page that calls "phpinfo();"

* Load it in a browser and look for the info on the xdebug module.

* If you see it, you have been successful!

http://github.com/mxcl/homebrew/commits/master/Library/Formula/xdebug.rb

看有提示我們修改php.ini,這就是我們要做的第二步。

(2)修改php.ini 檔案

因為我安裝的xmapp 所以找到預設的路徑:sudo vi /Applications/XAMPP/etc/php.ini

增加:

zend_extension="/usr/local/Cellar/xdebug/2.1.2/xdebug.so"

xdebug.remote_enable=1

xdebug.remote_host=localhost

xdebug.remote_port=9000

xdebug.remote_handler=dbgp

(3)重啟apache

在終端下以系統管理員root 的身份登入:

sudo su

使用下面的命令啟動XAMPP:

/Applications/XAMPP/xamppfiles/xampp start

您應該能在螢幕上看到類似下面的提示資訊:

Starting XAMPP for MacOS X 1.7.3...

XAMPP: Starting Apache with SSL (and PHP5)...

XAMPP: Starting MySQL...

XAMPP: Starting ProFTPD...

XAMPP for MacOS X started.

(4) 確認nb 調試連接埠

開啟netbeans ,選擇喜好設定,在調試器連接埠選擇如第二步中的9000連接埠。並且勾選 ‘在第一行停止’(可選),這是為了防止為打斷點就直接運行完了。

到此全部完成。其中需要注意一點的是,在建立PHP項目的時候,會讓你選擇調試的hosts , 記得要調試的url 別寫錯了。

作者 -274°C

http://www.bkjia.com/PHPjc/478521.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/478521.htmlTechArticle今天在MAC下,想調試PHP代碼,發現netbeans 掛不上斷點,根本調試不了。一番搜尋發現有個PHP的第三方模組叫xdebug ,雖然只找到一些windows 下...

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.