LoginSignup
1
1

More than 3 years have passed since last update.

【Xdebug 3.0】 VSCode + PHPDebug で Vagrant + VirtualBox 上のプロジェクトをデバッグ

Last updated at Posted at 2020-12-10

環境

仮想環境

  • Vagrant + VirtualBox
  • CentOS7
  • PHP 7.2
  • XDebug 3.0.1

ホスト環境

共有フォルダにプロジェクトが入っています。

何か

検索すればいろいろ出てくるVSCode + PHPDebugの利用方法ですが、最近XDebug3.0がリリースされ、元の状態ではデバッグできなくなってしまいました。。
いろいろ調べて、できた一例を載せます。

一例

仮想環境内

/etc/php.d/15-xdebug.ini
2行目   zend_extension=xdebug.so
84行目  xdebug.client_host = "10.0.2.2"
102行目 xdebug.client_port = 9003
788行目 xdebug.mode = debug,develop
974行目 xdebug.start_with_request = yes

PHPDebug設定

.vscode/launch.json
{
    // IntelliSense を使用して利用可能な属性を学べます。
    // 既存の属性の説明をホバーして表示します。
    // 詳細情報は次を確認してください: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Listen for Xdebug",
            "type": "php",
            "request": "launch",
            "port": 9003,
            "log": true,
            "pathMappings": {
                "path/to/project" : "${workspaceRoot}", //左側は仮想マシン内のプロジェクトのパス
            },
            "runtimeArgs" : [
                "-d", "xdebug.start_with_request=yes",
                "-d", "xdebug.mode=debug,develop",
            ]
        }
    ]

}

参考になるサイトはこちら

1
1
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
1
1