Hi, my name is Vitalii Rudnykh 👋

Jun 04, 2022

💻 Configuring Vim to work with xdebug [PHP]

Requirements:

  • VIM or NeoVIM.
  • A plugin that supports DBGP protocol (I use vdebug)
  • A PHP with extension Xdebug 3.

Configure:

  • Install the vdebug plugin. The installation process depends on which plugin manager you are using. (I recommend vim-plug). In my case, installing the plugin is by adding the following line to the config file vim (.vimrc for vim, init.vim for neovim).
Plug 'vim-vdebug/vdebug'
  • Add the following code to the config vim.
let g:vdebug_options = {}
let g:vdebug_options["port"] = 7000
  • Add to php.ini
xdebug.start_with_request=yes
xdebug.mode=debug,trace
xdebug.client_host=127.0.0.1
xdebug.client_port=7000

Please note, that Xdebug 3 has changed the name of many options. And these instructions will not work for you if you are using an older version of Xdebug.

Done, you can now debug the php-scripts.

  • F2: Step over.
  • F5: Start debug / to next breakpoint.
  • F6: Stop debugging (kills script).
  • F10: Toggle line breakpoint.
  • Double F6: Close the debugger interface.

For more information see documentation.