I downloaded the dll file by copy-pasting the phpinfo() output to Xdebug site, so I think I got the right file.
I edited my php.ini file and restarted Apache web server (I'm using XAMPP).
I set breakpoints, hit "Add Configuration" and Run the debug in Visual Studio Code.
Unfortunately, the breakpoint did not worked.
I have gone through many topics, tutorials but it still not works.
This is how my php.ini file looks like:
[XDebug]
zend_extension = "D:\xampp\php\ext\php_xdebug-3.0.4-8.0-vs16-x86_64.dll"
xdebug.remote_enable = 1
xdebug.remote_autostart = 1
This is my config file:
{
// 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": 9003
},
{
"name": "Launch currently open script",
"type": "php",
"request": "launch",
"program": "${file}",
"cwd": "${fileDirname}",
"port": 0,
"runtimeArgs": [
"-dxdebug.start_with_request=yes"
],
"env": {
"XDEBUG_MODE": "debug,develop",
"XDEBUG_CONFIG": "client_port=${port}"
}
},
{
"name": "Launch Built-in web server",
"type": "php",
"request": "launch",
"runtimeArgs": [
"-dxdebug.mode=debug",
"-dxdebug.start_with_request=yes",
"-S",
"localhost:0"
],
"program": "",
"cwd": "${workspaceRoot}",
"port": 9003,
"serverReadyAction": {
"pattern": "Development Server \\(http://localhost:([0-9]+)\\) started",
"uriFormat": "http://localhost:%s",
"action": "openExternally"
}
}
]
}
This is the image I took using the xdebug_info();
Your help save my day.
Your screenshot shows that you don't have the Step Debugger enabled (it says "Disabled").
Your config says:
zend_extension = "D:\xampp\php\ext\php_xdebug-3.0.4-8.0-vs16-x86_64.dll"
xdebug.remote_enable = 1
xdebug.remote_autostart = 1
Xdebug 3 does no longer use xdebug.remote_enable or xdebug.remote_autostart. As per the Upgrade Guide these have been renamed to:
xdebug.mode=debug
xdebug.start_with_request=yes
The "Docs" column in your screenshot also links to the documentation for that specific feature.
My solution after trying the instruction with windows and xampp:
Just download the xdebug extension again and do the instructions!
Related
I would like to know if there may be a way to run a debug step by step when click on input button type "submit". At this time I run the debug step by step with Xdebug but the problem is that I can't finding a way to start a debugging step by step when I send a form. Can you give me some advice please?
Unfortunately, from the answers I didn't understand what I have to do. I share some configuration information I have in my Virtual Machine.
I hope it can help :
I set /etc/php/8.0/cli/conf.d/20-xdebug.ini in this mode:
zend_extension=xdebug.so
xdebug.mode=debug
xdebug.start_with_request=yes
xdebug.client_host = localhost
xdebug.client_port = 9002
Here launch.json in VSCode (works only "Launch currently open script" but "Listen for Xdebug" and "Launch Built-in web server" don't work and i dont'know why):
{
"version": "0.2.0",
"configurations": [
{
"name": "Listen for Xdebug",
"type": "php",
"request": "launch",
"port": 9002
},
{
"name": "Launch currently open script",
"type": "php",
"request": "launch",
"program": "${file}",
"cwd": "${fileDirname}",
"port": 0,
"runtimeArgs": [
"-dxdebug.start_with_request=yes"
],
"env": {
"XDEBUG_MODE": "debug,develop",
"XDEBUG_CONFIG": "client_port=${port}"
}
},
{
"name": "Launch Built-in web server",
"type": "php",
"request": "launch",
"runtimeArgs": [
"-dxdebug.mode=debug",
"-dxdebug.start_with_request=trigger",
"-S",
"localhost:0"
],
"program": "",
"cwd": "${workspaceRoot}",
"port": 9002,
"serverReadyAction": {
"pattern": "Development Server \\(http://localhost:([0-9]+)\\) started",
"uriFormat": "http://localhost:%s",
"action": "openExternally"
}
}
]
}
You can use a hidden form variable with the name XDEBUG_SESSION and as value pretty much anything.
For this to work, you need to have:
Xdebug 3
Set xdebug.start_with_request=trigger
And all the standard configuration settings for enabling Step Debugging.
I'm using XAMPP and have installed Xdebug from Xdebug Wizard page, but renamed php_xdebug-3.0.2-7.2-vc15-x86_64.dll to php_xdebug.dll
My php.ini:
[XDebug]
xdebug.remote_enable=1
xdebug.remote_autostart=1
zend_extension="C:\xampp\php\ext\php_xdebug.dll"
my launch.json:
{
// 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
}
]
}
I have this extension installed:
When run I get this output in the console:
When I set the listen Xdebug:
And open the program it goes trough the breakpoint:
I'm trying to setup Xdebug on my VSCode, to do so I installed the PHP Debug extension and set the launch.json as so :
{
"version": "0.2.0",
"configurations": [
{
"name": "Listen for XDebug",
"type": "php",
"request": "launch",
"port": 9000,
"stopOnEntry": true,
"pathMappings": {
"/Users/me/Desktop/www/my_current_project": "${workspaceFolder}"
}
},
{
"name": "Launch currently open script",
"type": "php",
"request": "launch",
"program": "${file}",
"cwd": "${fileDirname}",
"port": 9000
}
]
}
For the extension on chrome I use Xdebug helper, and I'm not sure if it's supposed to work without cookie or not in the case of VSCode (because PHPStorm needs one), but I've set the cookie value to "VSCODE" as I found somewhere on the internet...and the extension is enabled (green).
Then, I clicked on "Listen for Xdebug" on VSCode, and set some breakpoints on my script, but VSCode does not respond to me calling the script from the browser.
I have not found so far any solution that worked for me, I guess there's an issue in the launch.json file maybe..
Here is my setup:
php.ini in xampp in found: /opt/lampp/etc/php.ini
[XDebug]
zend_extension=/usr/lib/php/20180731/xdebug.so
xdebug.remote_enable = 1
xdebug.remote_autostart = 1
This is what the phpinfo() looks like:
I am not able to step through the code or even set a breakpoint using the recommended PHP Debug plugin.
This is the default launch.json for VSCode.
{
"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
}
]
}
I saw in your phpInfo() ss that the port for xdebug is set to 9003 while your launch.json is listening to port 9000. Maybe this is the problem?
PHP debugging in vscode using xdebug and xampp is not working even after all configurations.
here is my php.ini file config:
zend_extension = D:\Xampp\php\ext\php_xdebug-3.0.0-7.3-vc15-x86_64.dll
[XDebug]
xdebug.remote_enable = 1
xdebug.remote_autostart = 1
this is json file
{
"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}"
}
]
}
xDebug 3 has changed several default values, so be sure your code is ready to work with new ones.
Here is my configuration set, which allowed me to use PHP breakpoints as always:
.vscode\launch.json
{
"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
}
]
}
php.ini (lines manually inserted in the end of a file)
[xdebug]
zend_extension = "php_xdebug-3.0.4.dll"
xdebug.mode = debug
xdebug.discover_client_host = 1
xdebug.start_with_request = yes
xdebug.client_port = 9000
Note: above zend_extension option would try to find your xdebug library in a .../modules/php/PHP_%your_php_version%/ext/ folder
I just got satisfaction with XDebug 3.
I found a good response here :https://github.com/felixfbecker/vscode-php-debug/issues/411 by jason-nabooki.
I do the same :
Json file :
"version": "0.2.0",
"configurations": [
{
"name": "Listen for XDebug",
"type": "php",
"request": "launch",
"port": 9003,
"stopOnEntry": true,
"log": true,
"pathMappings": {"/var/wwww/ammac":"${workspaceRoot}"}
},
{
"name": "Launch currently open script",
"type": "php",
"request": "launch",
"program": "${file}",
"cwd": "${fileDirname}",
"port": 9003
PHP.ini :
xdebug.mode= debug
xdebug.start_with_request = yes
xdebug.discover_client_host = true
To use the debugger (I didn't find immediatly due to my precedent use of Eclipse !),
first : click on the green triangle near "Listen for XDebug
second : refresh the web page in Firefox (or other)
For me it works i got the variables. Not yet test the breakpoints.
Remark : no need of the XDEbug helper in Firefox (surprise!)
In VSCode, I went to Settings -> Features -> Debug -> Allow Breakpoints Everywhere.
I check marked "Allow Breakpoints Everywhere" and I was able to debug again.
Struggled with this myself. Apparently XDebug 3.x doesn't work as outlined above. I found that even the equates under [XDebug] are no longer compatible. Download XDebug 2.x (I think 2.98 is the latest in the 2.x series). After I switched to 2.x, I'm no longer having any issue (so far).
https://xdebug.org/wizard - This tool helped me to find the reason why debuger didn't work.
Your are using xdebug version 3:
zend_extension = ... php_xdebug-3....
but in configuration you listen port 9000:
"port": 9000
The default Xdebug port changed between Xdebug v2 to v3 from 9000 to 9003.
Just change "port": 9000 => "port": 9003