May 14, 2014 —John Koster
Kint is a PHP tool that helps ease the pain of debugging PHP (which we all know is our favorite part of the job). This is what their website has to say:
Kint for PHP is a tool designed to present your debugging data in the absolutely best way possible.
Essentially what it does is takes PHP's output from the var_dump()
and debug_backtrace()
function and formats it nicely. Using Kint, you can look at a well organized representation of your arrays, objects, error messages and exceptions. Anything that var_dump()
accepts, really. Here is a shot of it displaying the $_SERVER
array:
While Kint is not really part of Laravel itself, using it in conjunction with Laravel's dd
function is a powerful combination. However, with Laravel's recent update, some users, including myself, were having issues getting Kint to work with Laravel. The solution that worked for me was to change the order of the dependencies in the composer.json
file.
composer.json
FileThis solution works by making sure that Kint is loaded before Laravel:
1"require": {2 ...3 "raveren/kint": "dev-master",4 "laravel/framework": "4.1.*"5 ...6}
After this change has been made, you will essentially have to perform a fresh composer install
for your project. This involves removing the composer.lock
file and the entire vendor
directory.
autoload_files.php
FileIf you do not want to remove your composer.lock
file or your vendor
directory, you can also manually adjust the autoload_files.php
file located in the vendor/composer/
directory. Again, just make sure that Kint is loaded before Laravel:
1<?php 2 3// autoload_files.php @generated by Composer 4 5$vendorDir = dirname(dirname(__FILE__)); 6$baseDir = dirname($vendorDir); 7 8return array( 9 10 ...11 $vendorDir . '/raveren/kint/Kint.class.php',12 $vendorDir . '/laravel/framework/src/Illuminate/Support/helpers.php',13 ...14);
The drawback to this method is that this change must be made every time composer updates your project's dependencies.
∎
The following amazing people help support this site and my open source projects ♥️
If you're interesting in supporting my work and want to show up on this list, check out my GitHub Sponsors Profile.