'My Xdebug is not working. Why isn't break points not working?
I have installed Xdebug with VS Code and Flywheel local and I am learning how to make themes. I have put a breakpoint in my index.php file. However, the said breakpoint is not working.
I am not getting any errors in my console. Nothing is happening in VS Code debug terminal when I load my site. It's just all blank. I have also installed PHP Debug extension in VS Code.
However, when I type in debug console anything I get this message - Cannot evaluate code without a connection.
What went wrong here?
My php.ini
[xdebug]
{{#if os.windows}}
zend_extension = php_xdebug.dll
{{else}}
zend_extension = {{extensions.xdebug}}
{{/if}}
xdebug.remote_enable=1
xdebug.remote_connect_back=Off
xdebug.remote_port="9000"
xdebug.profiler_enable=0
xdebug.remote_autostart = 1
xdebug.mode=debug
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,
"pathMappings": {
"C:/Users/ajayb/Local Sites/wordpress-theme-1/app/public": "${workspaceRoot}"
}
},
{
"name": "Launch currently open script",
"type": "php",
"request": "launch",
"program": "${file}",
"cwd": "${fileDirname}",
"port": 9000
}
]
}
Solution 1:[1]
I have faced the same problem. Local by FlyWheel installs Xdebug 2.7 for PHP 7.3 and XDebug 3.x when using PHP 7.4. If you are using PHP 7.4 modify the php.ini.hbs file and replace the xdebug section with the following:
xdebug.mode=debug
xdebug.client_port="9000" ; Default now is 9003
xdebug.start_with_request=yes
Solution 2:[2]
Yeap, as it was mentioned in a comment the main reason is https://xdebug.org/docs/upgrade_guide
I had the same issue with PHPStorm & Flywheel Local app v6+.
I set PHP 7.4.1 in Local and found in ~/projects/project-name/conf/php/php.ini.hbs
next v2 options:
xdebug.remote_enable=1
xdebug.remote_connect_back=Off
xdebug.remote_port="9000"
xdebug.profiler_enable=0
But when I checked var_dump(phpversion('xdebug'));
it ouptuted XDebug 3. It worked for me with v3 options:
xdebug.mode=debug
xdebug.start_with_request=trigger
xdebug.client_port="9003"
xdebug.discover_client_host=0
Solution 3:[3]
Even if you have XDebug's version 2.x.x, the default configuration is not enough.
You have to use the following for Xdebug v2.x.x:
xdebug.remote_enable = 1
xdebug.remote_autostart = 1
xdebug.remote_port = 9000
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | |
Solution 2 | Kostiantyn Petlia |
Solution 3 | Mooze |