筆者剛剛接觸PHP-Eclipse,今天剛把debug PHP的方法弄好,發出來與大家共用一下。
第一步:到Eclipse的官網去下載PHP-Eclipse:http://www.eclipse.org/downloads/packages/eclipse-php-developers/heliossr1
第二步:下載Xdebug (我用的是php_xdebug-2.1.0-5.2-vc6.dll,下載地址位於:http://xdebug.org/download.php),並且放入到"PHP5/ext"中
第三步:在PHP5裡面找到php.ini,在這個檔案的最後面加入如下配置資訊:
[Xdebug] zend_extension_ts="C:/Program Files/phpStudy/PHP5/ext/php_xdebug.dll" xdebug.auto_trace = On xdebug.show_exception_trace = On xdebug.remote_autostart = On xdebug.remote_enable = On xdebug.remote_host = 127.0.0.1 xdebug.remote_port = 9000 xdebug.remote_handler = dbgp xdebug.profiler_enable = on xdebug.profiler_output_dir="C:/Program Files/phpStudy/PHP5/log"
這裡要特別注意:如果在檔案裡有其他的zend_extension_ts,需要注釋掉,否則apache無法啟動。
第四步:啟動apache。
第五步:在eclipse的項目裡的Properties裡面找到"PHP Debug",在PHP Debugger裡面選擇"XDebug"
再配置一下:
第六步:再在Windows->Preferences裡面配置下PHP Servers
接下來,進入debug介面,就可以開始設定斷點進行debug了。