PHPackages                             kirik/web-profiler-php - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Debugging &amp; Profiling](/categories/debugging)
4. /
5. kirik/web-profiler-php

ActiveLibrary[Debugging &amp; Profiling](/categories/debugging)

kirik/web-profiler-php
======================

PHP library for WEB profiler

1.0(2y ago)19MITPHPPHP &gt;=7.0

Since Feb 19Pushed 5mo ago1 watchersCompare

[ Source](https://github.com/kirik/web-profiler-php)[ Packagist](https://packagist.org/packages/kirik/web-profiler-php)[ RSS](/packages/kirik-web-profiler-php/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (1)Versions (2)Used By (0)

PHP WEB Profiler
================

[](#php-web-profiler)

Motivation (or `why one more PHP debug bar?`): create a tiny profiling bar to use in multiple projects (not just a PHP backend). It should have no dependencies, easy integration into legacy projects, a small footprint, fast, and low overhead to run in production environments. Current solutions were not able to satisfy one or more requirements.

This library is a PHP backend to [WEB Profiler UI](https://github.com/kirik/web-profiler-ui) and uses it as a frontend. Please refer to [UI docs](https://github.com/kirik/web-profiler-ui/blob/main/README.md) to get more information regarding internals, features, and other perks.

[Click here](http://kirik.github.io/web-profiler-ui/) to see it in action.

[![Docked mode](https://raw.githubusercontent.com/kirik/web-profiler-ui/main/doc/docked_mode.png "Docked mode")](https://raw.githubusercontent.com/kirik/web-profiler-ui/main/doc/docked_mode.png)

Requirements
------------

[](#requirements)

Are specified in composer.json:

- PHP 7+ (as we have a tiny amount of code, we can easily make it work with PHP 5+)
- [web-profiler-ui](https://github.com/kirik/web-profiler-ui)
- That's pretty much it...

Installation
------------

[](#installation)

1. Install the package with the command:

```
composer require kirik/web-profiler-php
```

*As you can see, there is no `--dev` flag; that means we will be able to profile our pages on production too ;)*

2. Embed the profiler into your project (please see [example/main.php](example/main.php)):

```
// include composer autoloader
require('vendor/autoload.php');

// right after including composer, start profiling
\WebProfilerPhp\Profiler::start($_SERVER['REQUEST_URI'], []);

// application code
// ----

// at the very end of the application lifecycle, stop the profiler and render UI
echo \WebProfilerPhp\Profiler::render([]);
```

Until `Profiler::start` is called, no spans are being collected, and `Profiler::render` will return an empty string. Keeping that in mind, you can safely run it on production with almost no overhead on top. Personally, I prefer to use a cookie+IP condition to enable profiling:

```
if (isset($_COOKIE['__profiler']) && $_SERVER['REMOTE_ADDR'] === '127.0.0.1') {
    \WebProfilerPhp\Profiler::start($_SERVER['REQUEST_URI'], []);
}
```

and then use a browser bookmark to toggle the profiler:

```
javascript:(function(){const parts=`; ${document.cookie}`.split('; __profiler=');let enabled=(parts.length===2)?parseInt(parts.pop().split(';').shift()):0;document.cookie='__profiler='+(enabled>0?'0':'1')+'; path=/';if(confirm('Profiler has been '+(enabled>0?'disabled':'enabled')+'. Reload this page?')){document.location.reload();}})();

```

3. Add collectors/proxies to your application. Please refer to [example/main.php](example/main.php). Supported [collectors](#writing-your-own-collector):

- Database - used by PDO proxy, but you can use it on your own
- Log - just a simple logger
- PhpInfo - prints phpinfo() to the profiler

Base example of calling the Database collector:

```
$span = \WebProfilerPhp\Collector\Database::start('SELECT * FROM users WHERE id = 123');

// run query

// stopping span PHP7 style
if ($span !== null) {
    $span->stop(1);
}
// stopping span PHP8+ style using the null-safe operator
$span?->stop(1);
```

Supported [proxies](#proxies):

- PDO

4. add profiler response to your AJAX responses

```
$ajaxResponse = [/*some application response*/];

// adding __profiler key to the response (NOTE this will be added ONLY if the profiler was started)
$ajaxResponse = \WebProfilerPhp\Profiler::addProfilerToJson($ajaxResponse);

echo json_encode($ajaxResponse);
```

5. You're awesome!

Internals
---------

[](#internals)

The proxy is used to integrate well-known libraries and frameworks; PDO is the only supported proxy yet. Please don't hesitate to PR your proxy.

The collector is the entity that is used to measure/log events; they can be easily inherited/extended to provide your own metric.

### Proxies

[](#proxies)

#### PDO

[](#pdo)

Use `\WebProfilerPhp\Proxy\PDO` class as a proxy class for [PDO](https://www.php.net/manual/en/book.pdo.php).

```
$dbh = new \WebProfilerPhp\Proxy\PDO($dsn, $user, $password);
// ...
```

### Writing your own collector

[](#writing-your-own-collector)

Please extend `\WebProfilerPhp\Collector\Base` and override properties. You can also expand Database or Log collectors to implement the same logic. Please refer to [example/own\_collectors.php](example/own_collectors.php);

Roadmap
-------

[](#roadmap)

- add Guzzle proxy
- add MongoDB proxy
- add ClickHouse proxy
- add frameworks support (Laravel, Symfony, etc...)

Alternatives
============

[](#alternatives)

- [PHP Debug Bar](https://github.com/maximebf/php-debugbar)
- [Symfony web profiler](https://symfony.com/doc/current/profiler.html)
- [Laravel Telescope Dev Toolbar](https://laravel-news.com/laravel-telescope-dev-toolbar)
- [Drupal Debug Bar](https://www.drupal.org/project/debug_bar)

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance50

Moderate activity, may be stable

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity36

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

819d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/13ce11c14e7ab4da44a73dfb4b1882fc3b7b796ba23ca24a846ce0f700c091a8?d=identicon)[kirik](/maintainers/kirik)

---

Top Contributors

[![kirik](https://avatars.githubusercontent.com/u/929294?v=4)](https://github.com/kirik "kirik (16 commits)")

### Embed Badge

![Health badge](/badges/kirik-web-profiler-php/health.svg)

```
[![Health](https://phpackages.com/badges/kirik-web-profiler-php/health.svg)](https://phpackages.com/packages/kirik-web-profiler-php)
```

###  Alternatives

[symfony/stopwatch

Provides a way to profile code

2.8k387.2M918](/packages/symfony-stopwatch)[fruitcake/laravel-debugbar

PHP Debugbar integration for Laravel

19.1k662.9k29](/packages/fruitcake-laravel-debugbar)[spatie/ignition

A beautiful error page for PHP applications.

510147.6M69](/packages/spatie-ignition)[jokkedk/webgrind

Webgrind is a Xdebug profiling web frontend in PHP5. It implements a subset of the features of kcachegrind and installs in seconds and works on all platforms. For quick'n'dirty optimizations it does the job.

3.3k193.0k](/packages/jokkedk-webgrind)[koriym/printo

An object graph visualizer.

1421.8M2](/packages/koriym-printo)[soloterm/dumps

A Laravel command to intercept dumps from your Laravel application.

125285.7k3](/packages/soloterm-dumps)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
