1. Go to this page and download the library: Download iviphp/debug 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/ */
iviphp / debug example snippets
declare(strict_types=1);
use Ivi\Debug\Debug;
use Ivi\Debug\DebugManager;
$manager = new DebugManager();
$debug = new Debug($manager);
declare(strict_types=1);
use Ivi\Debug\Collectors\ExceptionCollector;
use Ivi\Debug\DebugManager;
$exceptions = new ExceptionCollector(
maximumExceptions: 25,
maximumTraceFrames: 50,
maximumPreviousDepth: 5,
declare(strict_types=1);
use Ivi\Debug\DebugManager;
use Ivi\Debug\Renderers\HtmlDebugRenderer;
$renderer = new HtmlDebugRenderer(
title: 'Application Debug',
declare(strict_types=1);
use Ivi\Debug\DebugManager;
use Ivi\Debug\Renderers\JsonDebugRenderer;
$renderer = new JsonDebugRenderer(
prettyPrint: true,
$renderer = new JsonDebugRenderer(
prettyPrint: false
);
$renderer = new JsonDebugRenderer(
$manager->setHtmlRenderer(
new HtmlDebugRenderer(
title: 'Custom Debug Page'
)
);
$manager->setJsonRenderer(
new JsonDebugRenderer(
prettyPrint: false
)
);
declare(strict_types=1);
use Ivi\Debug\Contracts\DebugCollectorInterface;
final class RuntimeCollector implements DebugCollectorInterface
{
private float $startedAt;
public function __construct()
{
$this->startedAt = microtime(true);
}
public function name(): string
{
return 'runtime';
}
public function collect(): array
{
return [
'duration_ms' => (
microtime(true)
- $this->startedAt
) * 1000,
'memory_bytes' => memory_get_usage(true),
'peak_memory_bytes' => memory_get_peak_usage(true),
];
}
public function count(): int
{
return 1;
}
public function isEmpty(): bool
{
return false;
}
public function reset(): void
{
$this->startedAt = microtime(true);
}
}
$debug->registerCollector(
new RuntimeCollector()
);