1. 程式人生 > >phpstorm + xdebug 遠端斷點除錯,詳解。

phpstorm + xdebug 遠端斷點除錯,詳解。

XDEBUG配置:

1.安裝 xdebug 略了。網上有很多資料。 

重點寫php.ini的配置 

 [XDebug]
   zend_extension="/usr/lib/php5/20090626+lfs/xdebug.so"
   xdebug.default_enable = On
   xdebug.collect_params = On

 xdebug.remote_connect_back = On           //如果開啟此,將忽略下面的 xdebug.remote_host 的引數。 <一臺webserver有多個開發者的工作目錄的時候使用,如:p1.xx.com,p2.xx.com,p3.xx.com 。。。等。 >
   xdebug.remote_host = 192.168.59.104    //注意這裡是,客戶端的ip<即IDE的機器的ip,不是你的web server>
   xdebug.remote_port = 9900                       //      注意這裡是,客戶端的埠<即IDE的機器的ip,不是你的web server>
   xdebug.remote_enable = On
  xdebug.remote_handler = dbgp
  xdebug.remote_log = "/var/www/xdebug/xdebug.log"
 xdebug.remote_req = req
 xdebug.auto_trace = Off
 xdebug.remote_autostart = On
 xdebug.show_exception_trace = 0
 xdebug.collect_vars = On
 xdebug.collect_return = On
 xdebug.collect_params = On
 xdebug.var_display_max_depth = 15
 xdebug.show_local_vars = 1
 xdebug.dump_undefined = 1
 xdebug.profiler_enable = 1
 xdebug.profiler_output_dir = /var/www/xdebug

PHPSTORM 配置:
1.file->setings->php|Debug右側。xdebug的那一塊。 設定Debug port:9900(這裡設定 的是,xdebug 吐出的debug資訊,通過本機的什麼埠傳輸。)

2.file->setings->php|Servers  右側。  host: 你的web伺服器的域名或ip ,埠,  下面的 use path mapping  意的是,你的專案的目錄,對應伺服器上的,什麼目錄?   這裡一定要設定哦! 不然,會發生找不到檔案而出錯,導至除錯終止。

3.Run->Edit Configurations-> 增加一個 PHP WEB APPlication 的除錯點。  右側: server 選擇你上面建立的server.  starturl 設定你的入口檔案。

至此,配置完畢!

這樣的請求,可以註冊一個除錯客戶端哦!

http://www.aihuxi.com/****.php?XDEBUG_SESSION_START=19192


點選,小蟲子圖示,即可,開始除錯!