kodhe / profiler
Kodhe profiler library
Requires
- php: >=8.1
Requires (Dev)
None
Suggests
None
Provides
None
Conflicts
None
Replaces
None
This package is not auto-updated.
Last update: 2026-10-28 11:37:14 UTC
README
A profiling package — a refactored version of the CodeIgniter 3 Profiler library under the Kodhe\Framework\Profiler namespace. It injects a debug panel at the bottom of an HTML page (or plain-text output) showing benchmarks, database queries, memory usage, URI, GET/POST, config, session, and HTTP headers. The architecture is modularized into per-section collectors and renderers (HTML/Text).
Installation
composer require kodhe/profiler
Requirements: PHP >= 8.1. No mandatory external dependencies.
Quick Start
<?php declare(strict_types=1); require __DIR__ . '/vendor/autoload.php'; use Kodhe\Framework\Profiler\Profiler; $profiler = new Profiler(); echo $pageHtml . $profiler->run(); // The debug panel is rendered at the end of the page output
Configuration & Section Selection
Sections are controlled via the sections configuration array or the explicit API:
$profiler = new Profiler([ 'sections' => [ 'benchmarks' => true, 'memory_usage' => true, 'get' => true, 'post' => false, ], ]); // Or at runtime: $profiler->disableSection('database'); $profiler->enableSection('config'); var_dump($profiler->isSectionEnabled('uri')); // bool
| Section | Collector | Description |
|---|---|---|
benchmarks |
BenchmarkCollector | Mark/named execution-time benchmarks |
queries / database |
DatabaseCollector | Queries + timings from the DB driver |
memory_usage |
MemoryCollector | Peak memory |
uri_segment / uri |
UriCollector | Request URI segments |
get / post |
— | Contents of $_GET / $_POST |
config |
ConfigCollector | Configuration items |
session_data |
SessionCollector | Session contents |
http_headers |
HttpHeadersCollector | Request/response headers |
The full list is available via $profiler->getAvailableSections().
Renderer
Two built-in renderers are available in src/Renderers/:
HtmlRenderer— CI3-style debug tables (default for HTML output).TextRenderer— suitable for CLI/logs.
Custom collectors can be registered directly:
use Kodhe\Framework\Profiler\Collectors\MyCustomCollector; $profiler->addCollector('my_metrics', new MyCustomCollector());
Directory Structure
src/
├── Profiler.php # Main class (CI3-compatible API)
├── Contracts/ # ProfilerInterface, CollectorInterface
├── Collectors/ # Benchmark, Database, Memory, Uri, Config,
│ # Session, Controller, HttpHeaders
├── Renderers/ # HtmlRenderer, TextRenderer
├── Factory/ # CollectorFactory, RendererFactory
├── Support/
├── ValueObjects/ # ProfileData, ProfileSection
└── language/profiler_lang.php
Migration Notes from the Old Namespace
Older docs/tests used Kodhe\Library\Profiler\Profiler and the disableAll() method. In the modern Composer version use:
use Kodhe\Framework\Profiler\Profiler;
To disable all sections, pass the 'sections' => [] configuration or call disableSection() per section. The PSR-4 mapping Kodhe\Framework\Profiler\ → profiler/src/ is declared in profiler/composer.json.