https://devilbox.readthedocs.io/en/latest/intermediate/configure-php-xdebug/editor-vscode.html#configure-php-xdebug-editor-vscode
It says PHPSTORM, not what the IDE key for Visual Studio code should be. Same issue with sublime.
eg: Ensure that xdebug.idekey is set to PHPSTORM in your PHP Xdebug configuration.
What is the IDE key for VSCode -> https://github.com/mac-cain13/xdebug-helper-for-chrome/issues/89
VSCODE
Also found the XDBUG documentation a little confusing with multilayered clickthroughs that make you quickly lose track of what you are doing. It would be simpler and more direct to have it on a single page with references at the bottom in my view.
I must admit I'm having similar issues, and I'm not able to use xdebug on vscode.
I have to admin the Xdebug documentation still has lots of potential. I made a major rewrite of this a few weeks ago, but its not yet in an easy and understandable shape.
I will dig into how to get this working with VSCode.
I will dig into how to get this working with VSCode.
I got it working, but just found it a little difficult to piece it together.
I used my original instructions re the IP address for the Docker ethernet adaptor. See the original issue I posted.
Here's how I got it working in VSCODE, very similar to my original solution here: https://github.com/cytopia/devilbox/issues/209
I don't know why you wrote such convoluted instructions tbh, Keep It Simple as devs are usually time poor would be my advice. Apart from that, a great tool so thanks! Goes well with Dockstation too, so you should also hook up with them.
XDebug.ini
; Xdebug
; Use these settings to enable Xdebug for PHP
; Make sure to read up on Xdebug some settings might significantly slow down requests.
; The following is just an example configuration and should be adjusted
xdebug.remote_enable = On
xdebug.remote_autostart = On
xdebug.remote_handler = dbgp
xdebug.remote_port = 9000
xdebug.idekey = VSCODE
xdebug.remote_log = /var/log/php/xdebug.log
xdebug.remote_connect_back=0
xdebug.remote_host=[IP Address of vEthernet (Default Switch) NOT the vEthernet (DockerNAT) IP - Note my solution here: https://github.com/cytopia/devilbox/issues/209 for getting the correct IP, it's different from yours]
PHP.ini
; ############################################################
; # Devilbox php.ini: Current default settings
; ############################################################
;
; Information
; -----------
; * Do not edit this file (it belongs to git)
; * This file shows example settings that are currently effective
; * If this file is enabled, nothing will change as it reflects the current default settings
;
; How to enable?
; --------------
; * Copy this file to another file with ".ini" extension
; * Only files with ".ini" extensions will be applied by PHP
;
; PHP.ini configuration
;
[PHP]
; Memory
; Note: "memory_limit" should be larger than "post_max_size"
memory_limit聽聽聽聽聽聽聽聽聽聽聽聽= 512M
; Timeouts
max_execution_time = 120
max_input_time = 120
; Uploads
; Note: "post_max_size" should be greater than "upload_max_filesize"
post_max_size = 72M
upload_max_filesize = 64M
max_file_uploads = 20
; Vars
variables_order = EGPCS
max_input_vars = 8000
max_input_nesting_level = 64
; Error reporting
; Note: error_log is dynamic and handled during start to set appropriate setting
error_reporting = E_ALL | E_NOTICE | E_STRICT | E_DEPRECATED
xmlrpc_errors = Off
report_memleaks = On
display_errors = On
display_startup_errors = On
track_errors = On
log_errors = On
html_errors = On
VSCode Launch.json for XDebug
{
// 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": {
"/shared/httpd/websitename/htdocs": "${workspaceRoot}/data/www/websitename/htdocs"
}
},
{
"name": "Launch currently open script",
"type": "php",
"request": "launch",
"program": "${file}",
"cwd": "${fileDirname}",
"port": 9000
}
]
}
I changed the pathMappings suggested with
"pathMappings": {
"/shared/httpd/xdebug/htdocs": "${workspaceFolder}/htdocs"
}
since it seems that ${workspaceRoot} is deprecated.
Struggled to get xdebug working, on Mac OS X (mojave), and Docker Desktop.
My solution was to add a loopback alias to the OS:
ifconfig lo0 alias 10.254.254.254
And give it a name in /etc/hosts
10.254.254.254 realhost
172.16.238.1 dockershost
Supported by invocation on boot:
/Library/LaunchDaemons/com.ralphschindler.docker_10254_alias.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.ralphschindler.docker_10254_alias</string>
<key>ProgramArguments</key>
<array>
<string>ifconfig</string>
<string>lo0</string>
<string>alias</string>
<string>10.254.254.254</string>
</array>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>
xdebug can now connect to realhost
Can also add it to
extra_hosts:
docker.for.lin.host.internal: 172.16.238.1
docker.for.lin.localhost: 172.16.238.1
docker.realhost: 10.254.254.254
Thanks for all the input. I am in the process of consolidating and simplifying the current Xdebug documentation and keep you posted as soon as the first PR is created.
@sonicviz @masiorama @keithy @drupalshift @toolowner
I have completely rewritten the Xdebug documentation and made sure it is as simple and straight forward as possible.
If anything is still unclear or not working, please comment again and I will re-open
Awesome, ty!
Most helpful comment
Here's how I got it working in VSCODE, very similar to my original solution here: https://github.com/cytopia/devilbox/issues/209
I don't know why you wrote such convoluted instructions tbh, Keep It Simple as devs are usually time poor would be my advice. Apart from that, a great tool so thanks! Goes well with Dockstation too, so you should also hook up with them.
XDebug.ini
; Xdebug
; Use these settings to enable Xdebug for PHP
; Make sure to read up on Xdebug some settings might significantly slow down requests.
; The following is just an example configuration and should be adjusted
xdebug.default_enable = On
xdebug.profiler_enable = On
xdebug.remote_enable = On
xdebug.remote_autostart = On
xdebug.remote_handler = dbgp
xdebug.remote_port = 9000
xdebug.idekey = VSCODE
xdebug.remote_log = /var/log/php/xdebug.log
xdebug.remote_connect_back=0
xdebug.remote_host=[IP Address of vEthernet (Default Switch) NOT the vEthernet (DockerNAT) IP - Note my solution here: https://github.com/cytopia/devilbox/issues/209 for getting the correct IP, it's different from yours]
PHP.ini
; ############################################################
; # Devilbox php.ini: Current default settings
; ############################################################
;
; Information
; -----------
; * Do not edit this file (it belongs to git)
; * This file shows example settings that are currently effective
; * If this file is enabled, nothing will change as it reflects the current default settings
;
; How to enable?
; --------------
; * Copy this file to another file with ".ini" extension
; * Only files with ".ini" extensions will be applied by PHP
;
; PHP.ini configuration
;
[PHP]
; Memory
; Note: "memory_limit" should be larger than "post_max_size"
memory_limit聽聽聽聽聽聽聽聽聽聽聽聽= 512M
; Timeouts
max_execution_time = 120
max_input_time = 120
; Uploads
; Note: "post_max_size" should be greater than "upload_max_filesize"
post_max_size = 72M
upload_max_filesize = 64M
max_file_uploads = 20
; Vars
variables_order = EGPCS
max_input_vars = 8000
max_input_nesting_level = 64
; Error reporting
; Note: error_log is dynamic and handled during start to set appropriate setting
error_reporting = E_ALL | E_NOTICE | E_STRICT | E_DEPRECATED
xmlrpc_errors = Off
report_memleaks = On
display_errors = On
display_startup_errors = On
track_errors = On
log_errors = On
html_errors = On
VSCode Launch.json for XDebug
{
// 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": {
"/shared/httpd/websitename/htdocs": "${workspaceRoot}/data/www/websitename/htdocs"
}
},
{
"name": "Launch currently open script",
"type": "php",
"request": "launch",
"program": "${file}",
"cwd": "${fileDirname}",
"port": 9000
}
]
}