LoginSignup
6
7

More than 3 years have passed since last update.

xdebug version 3になって動かなくなった

Posted at

はじめに

新年になったので、開発環境のDockerをビルドし直したら、xdebugでのステップ実行ができなくなった。
調べてみると、xdebugのVersion3になって設定項目名が変更されてしまったため、以前の設定が無効になってしまったのが原因でした。

TL;DR

以下の設定で動きました。
ちなみにデバッガ(IDE=phpstorm, vscode)の方の待受ポートは9003に合わせる必要があります。

xdebug.log=/tmp/xdebug.log
xdebug.mode=develop, debug
xdebug.start_with_request=yes
xdebug.client_host=host.docker.internal
xdebug.client_port=9003

zend_extension=/usr/local/lib/php/extensions/no-debug-non-zts-20170718/xdebug.so

v2時代の設定

たぶん、こんな設定がインターネットで検索するとでてくると思います。こちらはversion2までの設定になります。

xdebug.remote_enable=1
xdebug.remote_autostart=1
xdebug.remote_port=9003
xdebug.remote_host="host.docker.internal"
xdebug.remote_connect_back = 0
xdebug.remote_log=/tmp/xdebug.log

zend_extension=xdebug.so

xdebugのバージョン確認方法

php -vとするとwith Xdebug v3.0.2という風に表示されます。

root@57b67435355c:/# php -v
Cannot load Xdebug - it was already loaded
PHP 7.2.33 (cli) (built: Sep 10 2020 15:18:34) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
    with Xdebug v3.0.2, Copyright (c) 2002-2021, by Derick Rethans

動作確認(phpstorm)

phpstormを使っているので、xdebugの動作確認になります。
以下の画像中の矢印で示しているデバッグポートですが、もともと9000, 90003と書いてありましたが、③の検証を実行したところ、9003にするように指示があったので変更しています。

2021-01-07_10h40_09.png

画像の中では、xdebug.modeがdebugじゃないと警告がでていますが、公式ドキュメントには、以下のように複数設定が有効なようです。実際、ステップ実行は実現できました。

2021-01-07_10h44_56.png

参考文献

公式サイト一択じゃないかな。。。。

6
7
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
7