Git Product home page Git Product logo

kint's Introduction

Kint - debugging helper for PHP developers

Screenshot

What am I looking at?

At first glance Kint is just a pretty replacement for var_dump(), print_r() and debug_backtrace().

However, it's much, much more than that. You will eventually wonder how you developed without it.

Installation

One of the main goals of Kint is to be zero setup.

Download the file and simply

<?php

require 'kint.phar';

Or, if you use Composer:

composer require kint-php/kint --dev

Usage

<?php

Kint::dump($GLOBALS, $_SERVER); // pass any number of parameters
d($GLOBALS, $_SERVER); // or simply use d() as a shorthand

Kint::trace(); // Debug backtrace
d(1); // Debug backtrace shorthand

s($GLOBALS); // Basic output mode

~d($GLOBALS); // Text only output mode

Kint::$enabled_mode = false; // Disable kint
d('Get off my lawn!'); // Debugs no longer have any effect

Tips & Tricks

  • Kint is enabled by default, set Kint::$enabled_mode = false; to turn it completely off.
    The best practice is to enable Kint in a development environment only - so even if you accidentally leave a dump in production, no one will know.
  • See the buttons on the right of the output? Click them to open a new tab, show the access path for the value, or show a search box.
  • To see the output where you called Kint instead of the docked toolbar at the bottom of the page add the line Kint\Renderer\RichRenderer::$folder = false; right after you include Kint.
  • There are a couple of real-time modifiers you can use:
    • ~d($var) this call will output in plain text format.
    • +d($var) will disregard depth level limits and output everything.
      Careful, this can hang your browser on large objects!
    • !d($var) will expand the output automatically.
    • -d($var) will attempt to ob_clean the previous output and flush after printing.
    • You can combine modifiers too: ~+d($var)
  • Double clicking the + sign will open/close it and all its children.
  • Triple clicking the + sign in will open/close everything on the page.
  • Add heavy classes to the blacklist to improve performance:
    Kint\Parser\BlacklistPlugin::$shallow_blacklist[] = 'Psr\Container\ContainerInterface';
  • To change display theme, use Kint\Renderer\RichRenderer::$theme = 'theme.css';. You can pass the absolute path to a CSS file, or use one of the built in themes:
    • original.css (default)
    • solarized.css
    • solarized-dark.css
    • aante-light.css
  • Kint has keyboard shortcuts! When Kint is visible, press D on the keyboard and you will be able to traverse the tree with arrows, HJKL, and TAB keys - and expand/collapse nodes with SPACE or ENTER.
  • You can write plugins and wrapper functions to customize dump behavior!
  • Read the full documentation for more information

Authors

Jonathan Vollebregt (jnvsor)
Rokas Šleinius (raveren)

License

Licensed under the MIT License

kint's People

Contributors

jnvsor avatar raveren avatar aljinovic avatar rarst avatar tgr avatar grahamcampbell avatar will123195 avatar willzyx-dev avatar mcd-php avatar efalder413 avatar ulentini avatar sergeifilippov avatar plugowski avatar pborreli avatar niellles avatar larrybolt avatar eimajenthat avatar istvan-ujjmeszaros avatar frosas avatar vinculis avatar schlessera avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.