diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 472bff4..3f9cce6 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,5 +1,5 @@ { - "name": "PHP 7", + "name": "PHP Sample", "dockerFile": "Dockerfile", // Use 'settings' to set *default* container specific settings.json values on container create. diff --git a/.vscode/launch.json b/.vscode/launch.json index 675d51f..c69965a 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 9fb0872..014f265 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ This is a sample project that lets you try out the **[VS Code Remote - Containers](https://aka.ms/vscode-remote/containers)** extension in a few easy steps. -> **Note:** If you're following the quick start, you can jump to the [Things to try](#things-to-try) section. +> **Note:** If you're following the quick start, you can jump to the [Things to try](#things-to-try) section. ## Setting up the development container @@ -34,19 +34,27 @@ 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 This project welcomes contributions and suggestions. Most contributions require you to agree to a