Time-out connecting Xdebug in VSCode - php

I'm getting this error while I'm trying to debug some Laravel code in VSCode:
Xdebug: [Step Debug] Time-out connecting to debugging client, waited: 200 ms. Tried: localhost:9000 (through xdebug.client_host/xdebug.client_port) :-(
I have tried different ports but no change !
php.ini configuration :
xdebug.mode = debug
xdebug.start_with_request = yes
xdebug.client_port = 9000
launch.json configuration :
{
"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
},
{
"name": "Listen for XDebug on Homestead",
"type": "php",
"request": "launch",
"pathMappings": {
"/home/vagrant/Code/tighten-app-homestead": "/Users/jose/Code/tighten-app-homestead"
},
"port": 9000
}
]
}
Also, I'm on Windows, not Linux!

I was also searching for solutions after I fixed the debugging setting in WordPress using the answers by creator Derick.
Then I tested for Laravel and was facing the exact error you were facing. Then, looking closely at the setting, realized that we need to use port: 9003 instead of 9000
Check Out: https://xdebug.org/docs/upgrade_guide#Step-Debugging
Solution:
Change the port
"port": 9000
To
"port": 9003
Also, you can read my questions and answers at Xdebug shows method doesn't exist message

Related

Setup Xdebug configuration for PHP scripts called in cron by docker-entrypoint.sh in VSCode

Currently using VSCode on MacOS, Xdebug is working well for my PHP web application ran with docker.
But I also have some PHP scripts that are called by the docker-entrypoint.sh as crons and I'd like to be able to debug them as well. I can't configure it properly, nothing happens when I set breakpoints while the crons are running.
Here is my launch.json configuration at the moment (all the codesource - web, scripts...- is under myapp/app) :
{
"version": "0.2.0",
"configurations": [
{
"name": "Listen for Xdebug",
"type": "php",
"request": "launch",
"port": 9001,
"log": true,
"pathMappings": {
"/opt/myapp/app": "/Users/me/src/myapp/app"
}
},
{
"name": "Launch currently open script",
"type": "php",
"request": "launch",
"program": "${file}",
"cwd": "${fileDirname}",
"port": 9002,
"log": true
}
]
}
In my docker-compose.yml, I also have PHP_XDEBUG_ENABLED=true for the web container and the cron container of course.
Any ideas / configuration examples to get the debug working for the PHP crons ?

Xdebug is working but not stopping at breakpoints in VSCode

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:

Unable to get Xdebug to work on VSCode with browser extension

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

Cannot setup Xdebug in VSCode on XAMPP on Linux Mint

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?

XDebug not working in VScode for php debugging

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

Categories