2

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 F5it 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.

Screenshot of the first few lines of Page Source on Debug Console

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

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.