Kint
As developers, we already know that using the right debugging tools can really make it easier to track bugs or improve the co
Why do we need Debugging?
- Reports an error immediately so that we can detect the errors in its earlier stage.
- It assists the developer in reducing useless and distracting information.
Kint - a modern and powerful PHP debugging helper
What is it?
Kint for PHP is a tool designed to present your debugging data in the absolutely best way possible.
In other words, think of Kint as a modern tool to help you track your code with more flexibility.
We are already familiar with some PHP debugging functions like var_dump(), debug_backtrace(), get_defined_vars(), etc. But what if you got a magic toolbox that will wrap up all the essentials interface to debug your code?
In brief, Kint is a de facto addition to your development toolbox.
How to use Kint to Debug in Tiki Development?
Don't worry about long installation, importing, or namespacing... The developers community at Tiki decided to bundle Kint With new Tiki releases so it will make it easy to call all Kint functions at glance. https://gitlab.com/tikiwiki/tiki/-/commit/feb553ff5cba282c5c62d811ae58a15120923867
❗ Remember!
Before using Kint utility functions you have to access your shell and enable the developer mode.
Once you have access to your console interface, please run the following command from the root folder:
php console.php dev:configure
If you want to know more about the command please run
php console.php help dev:configure
What's next?
- You can use Kint in any PHP code from Tiki, for example:
Kint::trace(); // Dump a backtrace
and you can get information like:
- You can run Smarty Kint Modifier within the smarty template files: you sometimes run a case where you want to dump your variables from tpl files, with the "d" modifier available in Tiki (alias for Kint::dump()) you can backtrace your variables' metadata :
the syntax is :
{$varName|d}
example of output:
As you can see, we have even got a bunch of information about the variable.
Or with a Kint modifier as the parameter:
{$varName|d:'@'}
The full documentation of Kint can be read at Kint Docs