VVV logo VVV

VVV installs the Xdebug extension, a useful tool for development, here’s how their website describes it:

Xdebug is an extension for PHP to assist with debugging and development. It contains a single step debugger to use with IDEs; it upgrades PHP’s var_dump() function; it adds stack traces for Notices, Warnings, Errors and Exceptions; it features functionality for recording every function call and variable assignment to disk; it contains a profiler; and it provides code coverage functionality for use with PHPUnit.

Turning Xdebug On and Off

vagrant ssh -c "switch_php_debugmod xdebug"

Xdebug is turned off by default, but you can turn it on by SSH’ing into VVV with vagrant ssh, and running the command switch_php_debugmod xdebug. You can turn it off by running switch_php_debugmod none. Keep in mind that some commands such as composer will run slower with Xdebug turned on.

Once Xdebug is turned on, it will remain on until the next time VVV is provisioned.

Xdebug Modes

Currently when Xdebug is active it will be in the step debugger mode, with profiling and debug aids turned on. If you want to switch mode then you will need to modify config/php-config/xdebug.ini and adjust xdebug.mode=debug. To apply this change you must reprovision then activate Xdebug via switch_php_debugmod xdebug. In a future version we hope to integrate this into the switch_php_debugmod command.

Connecting Your IDE to Xdebug

Generic Instructions

Here are some general guidelines on connecting:

VSCode

VVV 3.6 and above includes a .vscode/launch.json preconfigured for Xdebug named VVV Listen for Xdebug. You will need to install the PHP Debug extension. Turn on Xdebug, and begin a debugging session in VSCode.

{
	"version": "0.2.0",
	"configurations": [
		{
			"name": "VVV Listen for Xdebug",
			"type": "php",
			"request": "launch",
			"port": 9003,
			"pathMappings": {
				"/srv/www/": "${workspaceRoot}/www/"
			}
		}
	]
}