XAMPP + PHP 7.4 + Xdebug 2.8.1 + VSCodeをつかってステップ実行環境設定を記載します
2.8と3以上では、設定が異なるので注意が必要です
1.Xdebug DLL の入手と設置
ブラウザで Xdebug公式ウィザード にアクセス
Xdebug: Support — Tailored Installation Instructionsphpinfo() の内容を貼り付けて「Analyse」 <?php phpinfo(); ?>
この画面をコピーして貼り付けるとダウンロード推奨のDLLを指示してくれる
表示された指示に従って、対応するDLLファイル(例:php_xdebug-2.8.1-7.4-vc15.dll) をダウンロード
現在はDownload php_xdebug-3.1.6-7.4-vc15-x86_64.dllになる
DLLファイルを C:\xampp\php\ext に保存
ファイル名を php_xdebug.dll に変更(任意)
2.php.ini にXdebug設定を追加
[Xdebug]
zend_extension = "C:\\xampp\\php\\ext\\php_xdebug.dll"
xdebug.remote_enable = 1
xdebug.remote_autostart = 1
xdebug.remote_port = 9000
xdebug.remote_host = 127.0.0.1
xdebug.idekey = esada
3.再起動
VSCodeに「PHP Debug」拡張をインストール
作者「Cdebug」のものをインストール!
VSCodeを開いて、拡張機能ビューで「PHP Debug」を検索
4.プロジェクトに launch.json を作成launch.json を作成して以下を記述:
VSCodeで C:\xampp\htdocs\order_mvp_mvs を開く.vscode フォルダを作成(なければ)
{
"version": "0.2.0",
"configurations": [
{
"name": "Listen for Xdebug",
"type": "php",
"request": "launch",
"port": 9000,
"stopOnEntry": true,
"pathMappings": {
"C:\\xampp\\htdocs\\order_mvp_mvs": "${workspaceFolder}"
}
}
]
}
5.ステップ実行の操作手順
VSCodeで public/index.php を開くphpinfo() で xdebug.mode が debug
行番号の左をクリックしてブレークポイントを設定
左の「デバッグ」ビューで「Listen for Xdebug」を選択 → ▶️ 実行
3.1以降の時はphp.ini
[Xdebug]
zend_extension = "C:\\xampp\\php\\ext\\php_xdebug.dll"
xdebug.mode = debug
xdebug.start_with_request = yes
xdebug.client_port = 9003
xdebug.client_host = 127.0.0.1
xdebug.idekey = esada
launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "Listen for Xdebug",
"type": "php",
"request": "launch",
"port": 9003,
"stopOnEntry": true,
"pathMappings": {
"C:\\xampp\\htdocs\\order_mvp_mvs": "${workspaceFolder}"
}
}
]
}