I'm trying to set up Xdebug to work in VSCode on a Windows environment with a Lighthouse / Laravel based server. My VSCode settings look like this
{
// 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've also tried adding a pathMappings to there with no luck
"pathMappings": {
"/graphql": "${workspaceRoot}/public"
}
I've followed https://laracasts.com/series/visual-studio-code-for-php-developers/episodes/13 and added all there suggested configurations. When I type php -v
PHP 7.4.10 (cli) (built: Sep 1 2020 16:52:21) ( NTS Visual C++ 2017 x64 )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
with Xdebug v3.0.0, Copyright (c) 2002-2020, by Derick Rethans
I do see Xdebug installed.
My php.ini looks like this
[XDebug]
zend_extension = "php_xdebug-3.0.0-7.4-vc15-nts-x86_64.dll"
xdebug.remote_enable = 1
xdebug.remote_autostart = 1
xdebug.remote_connect_back = 1
xdebug.remote_host=localhost
xdebug.idekey=VSCODE
xdebug.remote_log ="C:\tools\xdebug.log"
Any advice would be greatly appreciated
For anyone else with a similar problem just needed to upgrade my php.ini.
[XDebug]
zend_extension = "php_xdebug-3.0.0-7.4-vc15-nts-x86_64.dll"
xdebug.mode = debug
xdebug.start_with_request=yes
xdebug.idekey=VSCODE
Ended up something like this not even sure if the idekey is even necessary now.
That and change the port to 9003 as that changed in version 3 apparently.
Related
I have recently installed php debugger by Felix Becker.
No matter whatever config settings I do, my debugger is not hitting anything.
Following are my conf files.
xdebug.ini
[xdebug]
; debug
xdebug.default_enable = $value
xdebug.remote_autostart = $value
xdebug.remote_connect_back = 0
xdebug.remote_host = $value
xdebug.remote_port = $value
xdebug.remote_enable = 1
xdebug.idekey = $value
; profiling
xdebug.profiler_enable = 0
xdebug.profiler_output_dir = /tmp
zend_extension=xdebug.so
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": 9009,
"pathMappings": {
"path/path": "$value"
}
},
{
"name": "Launch currently open script",
"type": "php",
"request": "launch",
"program": "${file}",
"cwd": "${fileDirname}",
"port": 9009,
"pathMappings": {
"path/path": "$value"
}
}
]
}
Am I missing anything here ?
Xdebug v3.0.1, by Derick Rethans
You are using Xdebug v3 but keep using Xdebug v2 config parameters. You need to go through Upgrading from Xdebug 2 to 3 Guide and adjust your settings (mostly just change the parameter name).
Xdebug v3 uses different config params than Xdebug v2. From what I see 8 out of 9 "xdebug." params from your current php.ini do nothing in Xdebug v3.
For Xdebug 3 it should be something like this (based on your original config):
zend_extension=xdebug.so
[xdebug]
xdebug.mode = debug
; for profiling switch to below:
;xdebug.mode = profile
xdebug.client_host = ${PHP_XDEBUG_REMOTE_HOST}
xdebug.client_port = ${PHP_XDEBUG_REMOTE_PORT}
xdebug.discover_client_host = false
xdebug.start_with_request = ${PHP_XDEBUG_REMOTE_AUTOSTART}
xdebug.idekey = ${PHP_XDEBUG_IDE_KEY}
xdebug.output_dir = /tmp
P.S. xdebug.discover_client_host will now fallback to xdebug.client_host on failure (unlike v2 that would try autodetected host only).
P.P.S. xdebug.default_enable = 1 is replaced by xdebug.mode = develop. If you need that then you can list multiple values via comma, e.g. xdebug.mode = develop,debug
A fix for Becker extension was pushed in v1.52.1, see https://github.com/microsoft/vscode/issues?q=is:issue+milestone:%22November+2020+Recovery%22+is:closed
The php debugger extension by Felix Becker is using previously-deprecated api and so the last vscode version 1.52 means it won't hit breakpoints. There are many issues on vscode's github on this. A vscode team member suggests enabling this setting to fix:
Debug: Allow Breakpoints Everywhere
see https://github.com/microsoft/vscode/issues/112288#issuecomment-743456329
The other option is to use a different extension which has updated its code to accommodate the deprecations. For examples, see https://github.com/felixfbecker/vscode-php-debug/issues/424#issuecomment-727932756
I am trying to debug my php code for the drop downs. I have already gone through other posts on Stackoverflow but still not able to solve the issue.
I have extension installed for php debug, changed the settings in php.ini, launch.json. What else should I do?
launch.json file
{
"version": "2.6.0",
"configurations": [
{ "name": "Listen for Xdebug",
"type": "php",
"request": "launch",
"port": 3000,
},
{
"name": "Launch currently open script",
"type": "php",
"request": "launch",
"program": "${file}",
"cwd": "${fileDirname}",
"port": 3000
}
]
}
php.ini
[XDEBUG]
zend_extension="C:\PHP 7.0v\v7.0\ext\php_xdebug.dll"
xdebug.remote_enable = 1
xdebug.remote_autostart = 1
xdebug.show_local_vars = 1
xdebug.remote_connect_back = 1
xdebug.remote_handler = dbgp
;xdebug.remote_host = 127.0.0.1 before
xdebug.remote_host = 10.176.17.108
xdebug.remote_port = 3000
xdebug.remote_mode = req
[MYSQL]
Results for php -v:-
C:\Users\T0209964\Downloads\MDB-Free_4.8.1>php -v
PHP 7.0.30 (cli) (built: Apr 24 2018 16:30:41) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies
with Xdebug v2.6.0, Copyright (c) 2002-2018, by Derick Rethans
Everything looks fine. Try to enable logging in launch.json by adding "log": true and in xdebug config by adding xdebug.remote_log=/var/log/xdebug.log. Probably you will be able to see whats wrong.
I'm not sure that can be an issue but I'm also use option xdebug.idekey=VSCODE for configuration xdebug with vscode.
Also make sure you're using that php.ini which you're expected (eg. by running <?php phpinfo();)
Hi i have problem with configuring xDebug with VSCode i am using OS X
launch.json
{
"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
[xDebug]
zend_extension="/usr/lib/php/extensions/no-debug-non-zts-20160303/xdebug.so"
xdebug.remote_enable=1
xdebug.remote_port=9000
xdebug.remote_connect_back=1
xdebug.idekey=SOMEKEY
xdebug.remote_autostart=1
php -v
PHP 7.1.23 (cli) (built: Nov 7 2018 18:20:35) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2018 Zend Technologies
with Xdebug v2.5.5, Copyright (c) 2002-2017, by Derick Rethans
Can you help me please?
I'm trying to set up Xdebug with VScode, but whenever I set breakpoints it's just ignoring it.
I installed https://marketplace.visualstudio.com/items?itemName=felixfbecker.php-debug and followed the instructions (Windows), I also used the Xdebug Wizard, here is my configuration :
Vscode - launch.json
{
"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
zend_extension = D:\wamp\bin\php\php7.1.16\ext\php_xdebug-2.6.1-7.1-vc14.dll
[XDebug]
xdebug.remote_enable = 1
xdebug.remote_autostart = 1
xdebug.remote_host=localhost
xdebug.remote_port=9000
xdebug.remote_log=D:\wamp\logs\xdebug.log
Note: I can't find any logs, I probably didn't set it correclty but I don't know how to make it work either
php -v
$ php -v
PHP 7.1.16 (cli) (built: Mar 28 2018 21:27:36) ( ZTS MSVC14 (Visual C++ 2015) x8
6 )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2018 Zend Technologies
with Xdebug v2.6.1, Copyright (c) 2002-2018, by Derick Rethans
Thank you for reading !
I believe you may need the following in your php.ini:
xdebug.remote_connect_back=1
See the xdebug.ini for WPLib Box’s PHP container which definitely works with XDEBUG and VS Code.
I am using Visual Studio Code:
I have also installed the PHP Debug Extension Version 1.12.1. My PHP Version is:
>php --version
PHP 7.1.8 (cli) (built: Aug 1 2017 21:10:46) ( ZTS MSVC14 (Visual C++ 2015) x86 )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies
with Xdebug v2.5.5, Copyright (c) 2002-2017, by Derick Rethans
I have configured xdebug following the instructions on the PHP Debug plugin.
My settings inside my php.ini look like the following:
zend_extension = "C:\xampp\php\ext\php_xdebug-2.5.5-7.1-vc14.dll"
[XDebug]
xdebug.remote_enable = 1
xdebug.remote_autostart = 1
xdebug.remote_connect_back = 1
xdebug.idekey = "whatever"
When running phpinfo(); my xdebug shows correctly:
My launch.json file looks the following:
{
// 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
}
]
}
However, when running the configuration I get:
The error log looks like the following:
messageService.ts:126 Debug adapter process has terminated unexpectedly
e.doShow # messageService.ts:126
e.show # messageService.ts:105
_.onServerExit # rawDebugSession.ts:535
(anonymous) # rawDebugSession.ts:449
emitTwo # events.js:111
emit # events.js:194
__dirname.ChildProcess._handle.onexit # internal/child_process.js:215
Any suggestions what might be wrong with debugging?
I appreciate your replies!
Your vscode config looks fine (at least for pure-Windows PHP debugging). Your php.ini Xdebug config is unnecessarily filled with unimportant stuff (at least for debugging).
Get rid of the whole thing and try this minimal xdebug config:
[XDebug]
xdebug.remote_enable = 1
xdebug.remote_autostart = 0
xdebug.remote_connect_back = 1
xdebug.idekey = "whatever"
Then (if you use Chrome) you can use this extension to manage enabling/disabling debug sessions: Xdebug helper
Note: This is for debugging via browser - Chrome. I guess some equivalent plugin should exist for Firefox, but I haven't tried that. If you use Linux or WSL on Windows 10, you can enable debugging session by setting the proper environment variable like export XDEBUG_CONFIG="idekey=whatever" in Linux terminal. I suppose some equivalent exists with pure Windows command-line, but I haven't tried that, either.