LAMPlights Personal anecdotes from my experiences using the LAMP stack

27Mar/120

Evaluate multidimensional arrays using vim xdebug

I love vim. I love XDebug. I need it to evaluate multidimensional (or nested) arrays though and it does not seem to do that. Chris Hartjes tweeted about his frustration with arrays too and I decided to fix the problem. Turns out there is nothing to fix.

Turns out we need to tweak a default configuration settings to get this all to work. Open up your .vimrc and add the following line:

let g:debuggerMaxDepth = 3

That depth means you will be able to view the contents of a triply-nested array. That seemed like a sensible default to me. Now you can evaluate or get the property of any variable like normal.

Once the depth is set there is no way to change it during a debug session. You have to close the existing XDebug session, update the value and start a new session. I plan on changing this in a future release of the plugin.

Tagged as: , , No Comments
10May/112

Writing debuggable code

Coding standards are religious in nature, ranking high on the list near vim vs emacs.  Paul Reinheimer woke up many in the twitterverse with a simple post:

Paul Reinheimer handling errors early tweet

This got me thinking about why I prefer to write code the way I do.  I figure most people choose a standard because they are of the opinion that a certain style of coding is more readable and less error prone.  Others are forced to by the community they want to develop in, such as  PEAR or Zend Framework.  I choose my standard for one reason: debug-ability.