Skip to content

Instantly share code, notes, and snippets.

@raveren
Last active October 2, 2021 14:36
Show Gist options
  • Save raveren/eba373d8abb572b0528c73d145103f95 to your computer and use it in GitHub Desktop.
Save raveren/eba373d8abb572b0528c73d145103f95 to your computer and use it in GitHub Desktop.
Config file for Kint (php debug helper). More info: https://kint-php.github.io/kint/settings/
<?php
/* ####################################################################
* Original, changes welcome:
*
* https://gist.github.com/raveren/eba373d8abb572b0528c73d145103f95
*
* More info:
*
* https://kint-php.github.io/kint/settings/
*
* HOW TO USE?
*
* Add this file to the `autoload.files` configuration in composer.json:
*
* "autoload": {
* "psr-4": {
* "App\\": "src/"
* },
* "files": [
* "config/kint.php" <--------------- this line
* ]
* },
*
* Or, if you don't use Composer, just include this file anywhere after Kint is included.
* ################################################################## */
# don't kill the vibe if something's wrong
if (!class_exists('Kint\Renderer\RichRenderer')) {
return;
}
# disable the weird fold on the bottom of the page and just display Kint where it was called.
Kint\Renderer\RichRenderer::$folder = false;
# make it usable on php frameworks of 2021+
Kint\Parser\BlacklistPlugin::$shallow_blacklist[] =
'Psr\\Containe\\ContainerInterface';
# Everywhere a file path is displayed you can click on it to open directly in PhpStorm
# Requires plugin
# Phpstorm -> Settings -> Plugins -> Marketplace -> Remote Call.
Kint\Kint::$file_link_format = 'phpstorm://open?file=%f&line=%l';
# show full (not edited) path to files so I can click em in console
Kint\Kint::$app_root_dirs = [
realpath($_SERVER['DOCUMENT_ROOT']) => realpath($_SERVER['DOCUMENT_ROOT']),
];
##################################
# add convenient shorthand aliases
if (!function_exists('kd')) {
/**
* Alias of Kint::dump(); die; is compatible with symfony & laravel (it leaves their dd helper alone)
*/
function kd()
{
$args = func_get_args();
call_user_func_array(['Kint', 'dump'], $args);
die;
}
Kint::$aliases[] = 'kd';
}
if (! function_exists('ss')) {
function ss()
{
if (! Kint::$enabled_mode) {
return 0;
}
$stash = Kint::$enabled_mode;
Kint::$enabled_mode = Kint::MODE_TEXT;
$args = func_get_args();
$out = call_user_func_array(['Kint', 'dump'], $args);
Kint::$enabled_mode = $stash;
return $out;
}
Kint::$aliases[] = 'ss';
}
if (!function_exists('sd')) {
function sd()
{
$args = func_get_args();
call_user_func_array('ss', $args);
die;
}
Kint::$aliases[] = 'sd';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment