1. Go to this page and download the library: Download raveren/kint library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
raveren / kint example snippets
('Hello, 🌎!');
sage('Hello, 🌎!');
sage($GLOBALS, $_SERVER); // dump any number of parameters
saged($i); // alias for sage();die;
sage(1); // shortcut for dumping trace
~ss($var); // outputs plain text
$output = @ss($var); // returns output instead of displaying it
! sage($var); // ignores depth limit for large objects
+ sage($var); // auto-expands the view
print sd($var); // saves output into "sage.html" in the current directory
print ! sd($var); // saves output into "sage.html" while also ignoring the output depth limit!
~ss($var);
// is equivalent to:
Sage::enabled(Sage::MODE_TEXT_ONLY);
Sage::dump($var);
// instead of sage()
Sage::dump('this looks way less hacky (yeah right:)');
// equivalent to sage(1);
Sage::trace();
// a real-life test helper:
class TestHelper{
public function getVarDump(mixed $providedContext): string
{
if (! $providedContext) {
return '';
}
$state = Sage::saveState();
Sage::enabled(Sage::MODE_TEXT_ONLY);
Sage::$aliases[] = __CLASS__ . '::' . __FUNCTION__;
Sage::$returnOutput = true;
Sage::$displayCalledFrom = false;
$debugOutput = Sage::dump($providedContext);
Sage::saveState($state); // now reset settings to presumed defaults
return PHP_EOL . $debugOutput;
}
}
// we already saw:
sage($GLOBALS, $_SERVER);
// you can also go shorter for the same result:
s($GLOBALS, $_SERVER);
// or you can go the verbose way, it's all equivalent:
Sage::dump($GLOBALS, $_SERVER);
// ss() will display a more basic, javascript-free display (but with colors)
ss($GLOBALS, $_SERVER);
// to recap: s() or sage() - dumps. Add "d" to die afterwards: sd(), saged()
// preppend "s" to simplify output: ss(), ssage().
// works in combination, too: ssd() and ssagedd() will dump in "simple mode" and die!
// prepending a tilde will make the output *even more basic* (rich->basic and basic->plain text)
~d($GLOBALS, $_SERVER); // more on modifiers below
// show a trace
Sage::trace();
s(1); // shorthand works too!
s(2); // trace - but just the paths
Sage::dump( debug_backtrace() ); // you can even pass a custom result from debug_trace and it will be recognized
// dump and die debugging
sd($GLOBALS, $_SERVER); // dd() might be taken by your framework
saged($GLOBALS, $_SERVER); // so this is an equivalent alternative
ssd($GLOBALS, $_SERVER); // available for plain display too!
// this will disable Sage completely
Sage::enabled(false);
sd('Get off my lawn!'); // no effect
Sage::dump( microtime() ); // just pass microtime() - also works if you pass NOTHING: s();
sleep( 1 );
Sage::dump( microtime(), 'after sleep(1)' );
sleep( 2 );
sd( microtime(), 'final call, after sleep(2)' );
bash
composer
js
"autoload": {
"files": [
"config/sage.php" /* <--------------- create this file with your settings! */
]
}, ...
bash
docker compose run php composer build
# OR (see Makefile):
make build
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.