简体   繁体   中英

Visual Studio Code is not launching a browser when debuging a PHP Application [wordpress]

I am running on: Ubuntu v18.04.1 Visual Studio Code v1.35.1 PHP v7.2.19-0ubuntu0.18.04.1 xdebug v2.7.2 wordpress v5.2.1

I am trying to debug WordPress with visual studio code and its working, when I launch a debug session by pressing F5 it works, it stops at the break-points.

The problem is instead of launching a browser, vscode shows all the page source in the debug console and then ends the debug session.

调试控制台上页面源的前几行的屏幕截图

launch.json has the following options configured

{
    // 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,
            "program":"${workspaceRoot}/index.php",
            "pathMappings": {
                "/var/www/html/wordpress": "${workspaceRoot}"
            }

        },
        {
            "name": "Launch currently open script",
            "type": "php",
            "request": "launch",
            "program": "${file}",
            "cwd": "${fileDirname}",
            "port": 9000
        }
    ]
}

Thankyou for reading this question. I would appreciate any help

1st I am not sure if it helps but i think your error in :

"program":"${workspaceRoot}/index.php",
"pathMappings": {
"/var/www/html/wordpress": "${workspaceRoot}" }

is your wordpress folder inside html folder? html folder is default folder come with linux when you install apache, what about switching program and pathMapping place? like

"pathMappings": {  
   "/var/www/html/wordpress": "${workspaceRoot}"  
}
"program":"${workspaceRoot}/index.php",  

this may be off topic but i suggest you to use gulp with browserSync it very cool and if you used it once you will use it always trust me

this link will help you start it in 1 hour you wont regret it if you know what gulp can do even for wordpress it automate everything in short and much more if you go in depth in it more than vscode

BTW you can do the BrowserSync only and leave the rest
but its better to watch the whole video so you dont get error then modify it for your needs

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