From df591f421b424102be0cfdd5a2f859413f0e239f Mon Sep 17 00:00:00 2001 From: Chuck Lantz Date: Thu, 22 Aug 2019 23:55:39 +0000 Subject: [PATCH] Add info on debugging a server --- .vscode/launch.json | 14 ++++++++++++++ README.md | 12 ++++++++++-- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 675d51fe..c69965a9 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -8,6 +8,20 @@ "program": "${workspaceFolder}/index.php", "cwd": "${workspaceFolder}", "port": 9000 + }, + { + "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 } ] } \ No newline at end of file diff --git a/README.md b/README.md index e302fa0e..48af4a04 100644 --- a/README.md +++ b/README.md @@ -29,18 +29,26 @@ Some things to try: - Open `index.php` - Try adding some code and check out the language features. 1. **Terminal:** Press ctrl+shift+\` and type `uname` and other Linux commands from the terminal window. -1. **Build, Run, and Debug:** +1. **Run and Debug:** - Open `index.php` - Add a breakpoint (e.g. on line 4). - Press F5 to launch the app in the container. - Once the breakpoint is hit, try hovering over variables, examining locals, and more. 1. **Running a server:** - - From the terminal, run `php -S localhost:8000` + - From the terminal, run `php -S 0.0.0.0:8000` - Press F1 and run the **Remote-Containers: Forward Port from Container...** command. - Select port `8000`. - Click "Open Browser" in the notification that appears to access the web app on this new port. - Look back at the terminal, and you should see the output from your site navigations - Edit the text on line 21 in `index.php` and refresh the page to see the changes immediately take affect +1. **Attach debugger to the server:** + - Follow the previous steps to start up a PHP server and open a browser on port `8000` + - Press F1 and select the **View: Show Debug** command + - Pick "Listen for XDebug" from the dropdown + - Press F5 to attach the debugger + - Add a breakpoint to `index.php` if you haven't already + - Reload your browser window + - Once the breakpoint is hit, try hovering over variables, examining locals, and more. ## Contributing