Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

Improve dump() with kint - debugging helper

I want to advise me how I can add a function Kint() for Volt. This tool is visually me useful when debugging. Help me please. http://raveren.github.io/kint/ kint



37.8k

Hello

You just include it into your service file, take look example https://github.com/phanbook/phanbook/blob/master/core/config/services.php#L452



18.7k
Accepted
answer

I add function to compiler:

$view->registerEngines([
        '.volt' => function ($view, $di) {
            $config = $this->getConfig();

            $volt = new VoltEngine($view, $di);

            $volt->setOptions([
                'compiledPath' => $config->application->cacheDir,
                'compileAlways' => $config->dev_environment,
                'stat' => $config->dev_environment,
                'compiledSeparator' => '_'
            ]);

            $compiler = $volt->getCompiler();

            if ($config->dev_environment){

                $compiler->addFunction(
                    'kint',
                    function ($resolvedArgs, $exprArgs) {
                        return 'd('.$resolvedArgs.')';     // <-- kint function
                    }
                );
            }

            return $volt;
        },
        '.phtml' => 'Phalcon\Mvc\View\Engine\Php'
    ]);

in index.php

/**
* Debug
*/
        if($app->config->dev_environment){
            //require '../vendor/raveren/kint/Kint.class.php';
            Kint::$theme = 'solarized';

            $debug = new \Phalcon\Debug();
            $debug->listen();
        }

composer:

{

  "require": {
  },

  "require-dev": {
    "raveren/kint": "*"
  }

}

Work fine.

edited Sep '16

Now, this is useful!

Volt can have odd behaviour sometimes.

P.S. you cannot use both native Phalcon Debug component and Kint tool. You have to disable Kint in order to use Phalcon Debug and vice versa.

kint() == var_dump()

I will find out about the use of debug Phalcon.

But so far I have had no problem using the two, since kint is a var_dump ()

kint() == var_dump()

That is quite not true. Kint is much more than var_dump. Better than xdebug or similiar.