たんたんめん日記

ソシャゲ関連のなんでもやさん備忘録

【PHP】php-fpm + Xdebug remote + PHPStormでデバッグ

最近、EclipseからPHPStormに乗り換えました。

で、PHPStorm + Xdebugのリモートデバッグを設定してみたので、メモ的に。

php-fpmはデフォルトが9000ポートで、Xdebugとカブってしまいます。
そのあたりも考慮した設定です。

Webサーバー側の設定

remoteデバッグ以外の設定も混じっています。

# vim /etc/php.ini

zend_extension="/usr/lib/php/modules/xdebug.so";xdebug.soのディレクトリに適宜修正
xdebug.collect_vars=on
xdebug.collect_params=4
xdebug.dump_globals=on
xdebug.dump.GET=*
xdebug.dump.POST=*
xdebug.show_local_vars=on

xdebug.remote_enable = On
xdebug.remote_handler = dbgp
xdebug.remote_connect_back=1
xdebug.remote_port = 9001
xdebug.idekey = "mydebug"

PHPStorm設定

(Windows) File メニュー - Setting

(Mac) PhpStormメニュー - Preference…

から「PHP」設定を開く

「Servers」設定

リモートHTTPサーバーを追加

    例) 
    Name : MyServer
    Host: 192.168.0.100
    Port: 80
    Debugger Xdebug
    「Use path mapping」にチェック  
        ローカルファイルのパスを「File/Directory」から選択し、  
        「Absolute path on the server」にサーバー上でのファイルパスを記述

f:id:dnond:20130304195421j:plain

「Debug」設定

  • Xdebug」の「Debug Port」を9001に変更

f:id:dnond:20130304195402j:plain

「Run」メニュー「Debug…」の設定

  • 「Run」メニューから「Debug…」を選択。

  • フロートメニューが表示されるので「Edit Configurations…」を選択。

  • 「Defaults」の「PHP Remote Debug」を選択し、「Servers」から「MyServer」を選択、「Ide Key」を「mydebug」に設定。

f:id:dnond:20130304195339p:plain

ブックマークレットを作成

f:id:dnond:20130304195311p:plain

デバッグ開始

  • 適当にブレークポイントを設定
  • 上部メニューの電話マークが緑になっていることを確認しておく

f:id:dnond:20130304195239p:plain