Oliventech

Debugging PHP with XDebug using Visual Studio Code

You are here:HomeDebugging PHP with XDebug using Visual Studio Code

28 November 2017

Debugging PHP with XDebug using Visual Studio Code

Add this to your php.ini file:

[XDebug]
zend_extension = "D:\xampp\php\ext\php_xdebug.dll"
xdebug.remote_autostart = 1
xdebug.profiler_append = 0
xdebug.profiler_enable = 0
xdebug.profiler_enable_trigger = 0
xdebug.profiler_output_dir = "D:\xampp\tmp"
;xdebug.profiler_output_name = "cachegrind.out.%t-%s"
xdebug.remote_enable = 1
xdebug.remote_handler = "dbgp"
xdebug.remote_host = "127.0.0.1"
xdebug.remote_log = "D:\xampp\tmp\xdebug.txt"
xdebug.remote_port = 9000
xdebug.trace_output_dir = "D:\xampp\tmp"
; 3600 (1 hour), 36000 = 10h
xdebug.remote_cookie_expire_time = 36000

Install the XDebug extension in Visual Studio Code.

Open the code that needs to be debugged in Visual Studio Code, for example in the case of XAMPP it will be "D:\xampp\htdocs".

Happy debugging.