今天在MAC下,想調試PHP代碼,發現netbeans 掛不上斷點,根本調試不了。一番搜索發現有個PHP的第三方模塊叫xdebug ,雖然只找到一些windows 下的資料,但還是摸索著把調試環境搭建成功。 配置過程:- 安裝xdebug
- 修改php.ini
- 重啟apache
- 確認netbeans 的調試端口與xdebug 一致
(1)下載xdebug
我這里使用了brew, 如果對brew工具不熟悉的可以谷歌下。 首先習慣性搜索下: 終端里執行命令: 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 別寫錯了。
posted on 2011-11-23 23:12
-274°C 閱讀(3805)
評論(0) 編輯 收藏 所屬分類:
PHP 、
mac