Blog

How To Prevent var_dump From Being Truncated When Using Local By Flywheel

PHP’s var_dump is one of the most handy functions around, allowing you to see any sort of data in a practically human readable format. If you’re like me and do a lot of work with external APIs, it’s indispensable when it comes to figuring out the type of data your responses are.

Unfortunately if you use Local by Flywheel, var_dump gets truncated just a few levels down, which is rather inconvenient when you’re working with complex nested arrays and objects.

Thankfully this isn’t too hard to fix. Local uses a PHP extension called Xdebug, which has some settings to customise how var_dump works. These settings would normally be added to your php.ini file, but with Local by Flywheel that file is php.ini.hbs, and can be found in your Local Site Folder/conf/php.ini.hbs.

  1. Copy the below snippet.
  2. Paste it in the php.ini.hbs file. You can put it anywhere in the file, but ideally it should be placed near the bottom with the other Xdebug rules.
  3. Restart the local site

[gist https://gist.github.com/cameronjonesweb/6777ebaf5b0df9f4fc11afb4dc5dad5d]

You should now be free to see the contents of nested data no matter how many levels deep.

Did you find this post useful?

YesNo