Default entries for PHP debug (no launch.json file was present before that).
{
// 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
}
]
}
Created them using this way:
You can run through questions where both visual-studio-code & xdebug tags are present to see other possible configs (but usually that would be just default entries).
P.S. I had to add the following bit for Xdebug to actually try to debug (for "Launch currently open script" entry .. which runs the script in CLI environment). Without it it was just executing it (PhpStorm IDE is better in this regard as it automatically adds such bit when "Debug" button is used).
The IDE key can be anything, it just that this environment variable to be present (at very least here in my setup on Windows 10).
"env": {
"XDEBUG_CONFIG": "idekey=VSCODE"
},
this also works for me:
"env": {
"XDEBUG_CONFIG": ""
},
I've also tried"XDEBUG_SESSION": "1"
.. but it did not worked for me.
Without that (or when you cannot override it as you already have such environment variable with your own stuff) you may need to havexdebug.start_with_request = yes
in your php.ini (which tells Xdebug to try to debug every single script -- it's inconvenient to have it there as it will be applied to ALL PHP scripts that are run with that php.ini) .. or havexdebug_break();
in your PHP code.
Yet another way is to configure"program": "${file}"
line and specify PHP interpreter there as well as any Xdebug config (which also is not super convenient but is more flexible is certain scenarious, e.g. when you have multiple PHP on your system and have to run this script with non-default one), for example:
"program": "/path/to/php -dxdebug.mode=debug -dxdebug.client_port=9000 -dxdebug.client_host=127.0.0.1 -dxdebug.start_with_request=yes ${file}"
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Find the answer in similar questions on our website.
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.
PHP (from the English Hypertext Preprocessor - hypertext preprocessor) is a scripting programming language for developing web applications. Supported by most hosting providers, it is one of the most popular tools for creating dynamic websites.
The PHP scripting language has gained wide popularity due to its processing speed, simplicity, cross-platform, functionality and distribution of source codes under its own license.
https://www.php.net/
Welcome to the Q&A site for web developers. Here you can ask a question about the problem you are facing and get answers from other experts. We have created a user-friendly interface so that you can quickly and free of charge ask a question about a web programming problem. We also invite other experts to join our community and help other members who ask questions. In addition, you can use our search for questions with a solution.
Ask about the real problem you are facing. Describe in detail what you are doing and what you want to achieve.
Our goal is to create a strong community in which everyone will support each other. If you find a question and know the answer to it, help others with your knowledge.