Linux, PHP

Vdebug: Xdebug not showing full array contents

Vim editor

Have you ever tried to debug some PHP code in Vim just to find that Xdebug won’t show the full array contents?

Fortunately the DBGP protocol allows you to set features for debugging, such as the max length of data that the debugger returns. You can set these features in the Vim dictionary g:vdebug_features, and they will be sent to the debugger when you start a new debugging session.ยน

In our case, we need to set a higher limit for the max_children option. Add the following snippet to your .vimrc file:

" :help Vdebug, #VdebugFeatures:
" For example:
" let g:vdebug_features['max_depth'] = 2048
"
" max number of array or object children to initially retrieve
let g:vdebug_features = { 'max_children': 512 }

The next time you start a debugging session, you’ll see that the number of elements listed for arrays is a lot higher. Feel free to adjust the value to better suit your needs.

That’s it. See you around.

1. See: vDebug Help (:help VdebugFeatures)

2. See: Vdebug Features

Tagged , , , , , , ,

Leave a Reply

Your email address will not be published. Required fields are marked *