简体   繁体   中英

Visual Studio Code debugger not launching browser window or displaying variables

I'm running a debugging session in Visual Studio Code. I was expecting two things to happen that didn't.

  1. For a browser window to open when I launched 'run and debug'.
  2. To see a list of variables and their values.

First, I downloaded the Xdebug extension.

在此处输入图像描述

Next, I set a breakpoint on my php file.

在此处输入图像描述

Lastly, I clicked the 'run and debug' button.

I'm hoping someone can offer some advice on where I'm going wrong.

Thanks, Kyle

Check your ports, I recommend using some that you remember, example: default.

I recommend you install php with brew, since with MAMP, XAMP, etc. there is less information in case of error.

brew tap shivammathur/php 
brew install shivammathur/php/php@7.3

This tool gave me a lot of headaches at work, however, on MacOs we have to do a lot of steps.

I recommend that you remember how to install it as it is, because sometimes Visual Studio Code changes the ports when updating.

Xdebugger installation

These three files are the most important to modify (with nano, vim, etc.)

php.ini

  • Location: /usr/local/etc/php/7.3/php.ini
...
; Local Variables:
; tab-width: 4
; End:
xdebug.remote_enable = 1
xdebug.remote_autostart = 1
xdebug.remote_port = 9000

99-xdebug.ini

  • Location: /usr/local/etc/php/7.3/conf.d/99-xdebug.ini
zend_extension = "/usr/lib/php/extensions/no-debug-non-zts-20180731/xdebug.so"
xdebug.mode=debug
xdebug.start_with_request = yes
xdebug.remote_autostart = 1

Visual Studio Code

settings.json

Important : xdebug.remote_port, Listen for Xdebug, Launch currently open script are the same port.

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "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
        }
    ]
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM