Setting Up Debugging in PHP (w VS Code)

I used this page as my guide.

Setting Up XDebug

  1. Open this page in our browser
  2. Copy the entire contents of the HTML in the page.
  3. Go to this page and paste the clipboard contents into the textarea. Then press the 'analyze' button.
  4. Follow the instructions output.
    Note that the instructions did not tell me to set add these settings to the php.ini as well:
    xdebug.remote_autostart = 1
    xdebug.remote_enable = 1

Install the PHP Debug Plugin into VS Code

  1. In VS Code, press the 'Extensions' button (it's the icon on the left side that has 4 little boxes, and one of them is slightly separated from the others).
  2. The Extensions side bar will appear on the left.
  3. In the search box, enter PHP Debug. Go ahead and install it (press the 'Install' button).
  4. You may be prompted to restart VS code. If so, then do it.
  5. When VS Code restarts, click on File > Preferences > Settings
  6. Then click on the little icon in the upper right that will show the code (JSON) for the VSCode settings
    VSCode settings
  7. Add this entry (between the curly braces) to the user settings:
    "php.validate.executablePath": "C:\\xampp\\php\\php.exe"                    
                    
    You may, or may not, have other settings in the JSON code. Note that each line within the curly braces should end with a comma, except for the last one.
    VSCode settings in JSON
    Note, I got a warning saying that the settings could not be validated! But I ignored it, and everything worked.

Using the Debugger