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

Free Web Hosting

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
xdebug.var_display_max_depth = -1
xdebug.var_display_max_children = -1
xdebug.var_display_max_data = -1
view raw php.ini.hbs hosted with ❤ by GitHub

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

Did you find this post useful?