How To Prevent var_dump From Being Truncated When Using Local By Flywheel
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.
- Copy the below snippet.
- Paste it in the
php.ini.hbsfile. You can put it anywhere in the file, but ideally it should be placed near the bottom with the other Xdebug rules.
- Restart the local site
|xdebug.var_display_max_depth = -1|
|xdebug.var_display_max_children = -1|
|xdebug.var_display_max_data = -1|
You should now be free to see the contents of nested data no matter how many levels deep.