MacOS Sierra、PhpStorm、Xdebugを使用すると、Webアプリケーションがポート80(PhpStormから実行されていない)で設定されます。PhpStorm + Xdebugは、外部IPアドレスを使用する場合にのみブレークポイントにヒットします
localhost:80/index.php
にブラウズすると、PhpStormはブレークポイントで停止しません。外部IP 192.168.1.2/index.php
にアクセスすると、PhpStormはブレークポイントにヒットします。
外部IPの代わりにlocalhost
をデバッグに使用したいと思います。
localhost
とPhpStormを連携させる方法はありますか?
P.S. Visual Studioコードは両方のシナリオで動作します(したがって、XdebugとPhpStormはうまく動作していると思います)。
[xdebug]
zend_extension = /usr/local/Cellar/php56/5.6.29_5/lib/php/extensions/debug-non-zts-20131226/xdebug.so
xdebug.remote_enable=1
xdebug.remote_handler=dbgp
xdebug.remote_port=9000
xdebug.remote_autostart=1
xdebug.remote_connect_back=1
xdebug.idekey=vagrant
xdebug.remote_host=0.0.0.0
はxdebug.remote_hostに127.0.0.1とlocalhostの、同じ動作を設定しようとしました。
ローカルホストデバッグ:80、Xdebugのログ表示:
Log opened at 2017-01-03 14:06:36
I: Checking remote connect back address.
I: Checking header 'HTTP_X_FORWARDED_FOR'.
I: Checking header 'REMOTE_ADDR'.
I: Remote address found, connecting to ::1:9000.
W: Creating socket for '::1:9000', poll success, but error: Operation now in progress (19).
E: Could not connect to client. :-(
Log closed at 2017-01-03 14:06:36
VSコードを使用する場合は、エラーとはXdebugがないxdebug.remote_connect_back
(デフォルト値)を0に設定代わりI: Connected to client. :-)
PhpStormの設定を共有してください。今のところ、IPアドレスのみのためにPhpStormに "debug server"エントリを作成している可能性があります - 'Settings/Preferences |言語とフレームワーク| PHP |サーバー。それがあれば、xdebug関連のログを収集してください(IDEとxdebugの両方から)。 – LazyOne
*(参照用)* PhpStormフォーラムでも同じです - https://intellij-support.jetbrains.com/hc/en-us/community/posts/115000010444-PHPStorm-Xdebug-hits-a-breakpoint-only -when-using-external-IP-address – LazyOne
おかげで@LazyOne、私はサーバー設定を変更しようとしましたが、PHPStormが接続を検出したとき(外部IP経由で接続しているとき)に自動的に作成されます。 – Ofiris