LoginSignup
0
1

More than 3 years have passed since last update.

VScodeでXdebugでデバックするときの、実行方法

Last updated at Posted at 2020-09-20

こんにちは! kouです。
今日は、vscodeでxdebugを使うために注意すべきことについて説明します!
この記事は、Visual Studio CodeでPHPをデバッグする方法に、補足を加えたものです

実施環境

lunch.jsonファイル

実行したいファイルがあるフォルダーを開き、実行したいファイルを選択>左メニューバーからデバッグボタンをクリック
create-launch.json.PNG
"launch.jsonファイルを作成します"をクリックし、PHPを選択launch.PNG

launch.jsonに、["runtimeExecutable": "C:\xampp\php\php.exe"]という行を追加し、下記のように修正。"runtimeExecutable"パスには、php.exeのpathを入力

*修正後

lunch.json
{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Listen for XDebug",
            "type": "php",
            "request": "launch",
            "port": 9000
        },
        {
            "name": "Launch currently open script",
            "type": "php",
            "request": "launch",
            "program": "${file}",
            "cwd": "${fileDirname}",
            "port": 9000,
            "runtimeExecutable": "C:\\xampp\\php\\php.exe"
        }
    ]
}

デバックの方法1-Webサーバーを使わないでデバック

「Launch currently open script」が選択されていることを確認し、デバック開始ボタンを押す
launch-current.PNG

デバックの方法2-Webサーバーからデバック

xmappで、Actions>Start からapacheを起動し、adminをクリックxmapp-ctrl.PNG
すると、このような画面が開く
localhost.PNG
そこで、vscode上で、左サイドバー>listen for XDebugをクリック
その状態でapache上から実行したいファイルを開くと、デバッグができる

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