PHPackages                             davihu/prophiler - 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. davihu/prophiler

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

davihu/prophiler
================

PHP Profiler &amp; Developer Toolbar built for Phalcon

022PHP

Since Sep 16Pushed 8y ago1 watchersCompare

[ Source](https://github.com/davihu/prophiler)[ Packagist](https://packagist.org/packages/davihu/prophiler)[ RSS](/packages/davihu-prophiler/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependenciesVersions (2)Used By (0)

Prophiler - A PHP Profiler &amp; Developer Toolbar built for Phalcon
====================================================================

[](#prophiler---a-php-profiler--developer-toolbar-built-for-phalcon)

[![Scrutinizer Code Quality](https://camo.githubusercontent.com/06bd80ea75371564b41326ab2baebec03bb41b8235bcdcc59915bc6066914fcf/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6661626675656c2f70726f7068696c65722f6261646765732f7175616c6974792d73636f72652e706e673f623d646576656c6f70)](https://scrutinizer-ci.com/g/fabfuel/prophiler/?branch=develop)[![Code Coverage](https://camo.githubusercontent.com/7287315c8a3010ad6a40f1014efdca580fe76c74616023f7512c8f0cc1c1c76e/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6661626675656c2f70726f7068696c65722f6261646765732f636f7665726167652e706e673f623d646576656c6f70)](https://scrutinizer-ci.com/g/fabfuel/prophiler/?branch=develop)[![Build Status](https://camo.githubusercontent.com/337841b3786e5ddc9ece8f35ae2a3212f606aa5d05fb8a9d8fd6797daa3722ee/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6661626675656c2f70726f7068696c65722f6261646765732f6275696c642e706e673f623d646576656c6f70)](https://scrutinizer-ci.com/g/fabfuel/prophiler/build-status/develop)[![License](https://camo.githubusercontent.com/06c24a67fbe4862de5d86c808168f0df4dc9de7e22f6fdb7a676b330e8ada145/68747470733a2f2f706f7365722e707567782e6f72672f6661626675656c2f70726f7068696c65722f6c6963656e73652e737667)](https://packagist.org/packages/fabfuel/prophiler)[![Latest Stable Version](https://camo.githubusercontent.com/76e1eb8abbd9b594a12b4fd2d011a9f3634d5cfb36e840c72bac21bedd2c7abc/68747470733a2f2f706f7365722e707567782e6f72672f6661626675656c2f70726f7068696c65722f762f737461626c652e737667)](https://packagist.org/packages/fabfuel/prophiler)

Demo
----

[](#demo)

The demo website has been moved to a separate repository:

Here you can see the toolbar in action:

[![Timeline Preview](https://camo.githubusercontent.com/2c08b6e8ac179dfbf45addd7813e497665d52e31090fb34137871e311d0cb52e/687474703a2f2f70726f7068696c65722e6661626675656c2e64652f696d672f74696d656c696e652e706e67)](http://prophiler.fabfuel.de/)

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

[](#installation)

You can use composer to install the Prophiler. Just add it as dependency:

```
"require": {
   	"fabfuel/prophiler": "~1.0",
}

```

Setup (general)
---------------

[](#setup-general)

Setting up the Prophiler and the developer toolbar can be done via the following simple steps. It could all be done in your front-controller (e.g. `public/index.php` in Phalcon)

### 1. Initialize the Profiler (as soon as possible)

[](#1-initialize-the-profiler-as-soon-as-possible)

Generally it makes sense to initialize the profiler as soon as possible, to measure as much execution time as you can. You should initialize the profiler in your front-controller or the bootstrap file right after requiring the Composer autoloader.

```
$profiler = new \Fabfuel\Prophiler\Profiler();
```

### 2. Initialize and register the Toolbar

[](#2-initialize-and-register-the-toolbar)

To visualize the profiling results, you have to initialize and render the Prophiler Toolbar. This component takes care for rendering all results of the profiler benchmarks and other data collectors. Put that at the end of the front-controller.

You can also add other data collectors to the Toolbar, to show e.g. request data like in this example.

```
$toolbar = new \Fabfuel\Prophiler\Toolbar($profiler);
$toolbar->addDataCollector(new \Fabfuel\Prophiler\DataCollector\Request());
echo $toolbar->render();
```

You can also easily create you own data collectors, by implementing the `DataCollectorInterface` and adding an instance to the Toolbar.

```
...
$toolbar->addDataCollector(new \My\Custom\DataCollector());
...
```

Additional setup for Phalcon applications
-----------------------------------------

[](#additional-setup-for-phalcon-applications)

### 1. Add the profiler to the dependency injection container

[](#1-add-the-profiler-to-the-dependency-injection-container)

Add the profiler instance to the DI container, that other plugins and adapters can use it across the application. This should be done in or after your general DI setup.

```
$di->setShared('profiler', $profiler);
```

### 2. Initialize the plugin manager

[](#2-initialize-the-plugin-manager)

The plugin manager registers all included Phalcon plugins automatically and attaches them to the events manager. To make the plugins work properly, make sure that the default events manager is attached to your Dispatcher, View and Connection services.

```
$pluginManager = new \Fabfuel\Prophiler\Plugin\Manager\Phalcon($profiler);
$pluginManager->register();
```

Custom Benchmarks
-----------------

[](#custom-benchmarks)

You can easily add custom benchmarks to your code:

```
$benchmark = $profiler->start('\My\Class::doSomething', ['additional' => 'information'], 'My Component');
...
$profiler->stop($benchmark);
```

### Or stop without passing the benchmark

[](#or-stop-without-passing-the-benchmark)

In some scenarios (e.g. custom adapters) it might be hard to pass the received benchmark to the `stop()` method. Alternatively you can simply omit the `$benchmark` parameter. If that is the case, the profiler simply stops the last started benchmark, but it is not possible to run overlapping benchmarks.

```
$profiler->start('\My\Class::doSomeOtherThing', ['additional' => 'information'], 'My Component');
...
$profiler->stop();
```

Aggregations
------------

[](#aggregations)

Prophiler now features benchmark aggregations. These give you a lot more insights and are extremely useful to:

- quickly see the total number of recurring executions (e.g. database or cache queries)
- analyze minimum, maximum and average execution times of recurring executions
- easily see (e.g. accidentally) recurring executions of the same database query
- get a warning, if the total number of executions exceeds a custom threshold
- get a warning, if the maximum execution time exceeds a custom threshold

### Setup

[](#setup)

Prophiler comes with some aggregators, but you can easily create your own. To Set up an aggregator, all you need to do is to register the aggregator at the profiler instance:

```
$profiler->addAggregator(new \Fabfuel\Prophiler\Aggregator\Database\QueryAggregator());
$profiler->addAggregator(new \Fabfuel\Prophiler\Aggregator\Cache\CacheAggregator());
```

That's it. You immediately see all database and cache queries, grouped by command/query, including the total number of executions, the total duration of all executions as well as the minimum, maximum and average execution time.

Logging
-------

[](#logging)

You can use Prophiler to log events and other data and view it in the timeline and in the separate "Logs" tab. If you already have a logging infrastructure, you can add the PSR-3 compliant `Logger` adapter to it. Otherwise you can also just instantiate and use it directly:

```
$logger = new \Fabfuel\Prophiler\Adapter\Psr\Log\Logger($profiler);
$logger->warning('This is a warning!', ['some' => 'context']);
$logger->debug('Some debugging information', ['query' => ['user' => 12345], 'foo' => 'bar']);
```

Adapters and Decorators
-----------------------

[](#adapters-and-decorators)

### Doctrine

[](#doctrine)

To profile all SQL queries made by Doctrine, you just have to register the SQLLogger adapter in your Doctrine configuration, for example in your `bootstrap.php` like that:

```
$sqlLogger = new Fabfuel\Prophiler\Adapter\Doctrine\SQLLogger($profiler);
$entityManager->getConnection()->getConfiguration()->setSQLLogger($sqlLogger);
```

### PDO

[](#pdo)

To profile your PDO database actions, you can use the Prophiler PDO decorator. It will record all `query()` &amp; `exec()` calls and prepared statements as well. Just decorate your PDO instance with the Prophiler decorator and use that instead:

```
$pdo = new PDO('mysql:host=localhost;dbname=test', 'user', 'password');
$db = new \Fabfuel\Prophiler\Decorator\PDO\PDO($pdo, $profiler);

$db->query('SELECT * from users');
$db->exec('DELETE FROM users WHERE active = 0');
$db->prepare('SELECT * from users WHERE userId = ?');
```

### Cache

[](#cache)

To profile Phalcon cache backend requests, you only need to decorate the cache backend with the BackendDecorator. It will benchmark all cache operations automatically. Here is an example with the APC backend:

```
$cacheFrontend = new \Phalcon\Cache\Frontend\Data(['lifetime' => 172800]);
$cacheBackend = new \Phalcon\Cache\Backend\Apc($cacheFrontend, ['prefix' => 'app-data']);

$cache = \Fabfuel\Prophiler\Decorator\Phalcon\Cache\BackendDecorator($cacheBackend, $profiler);
```

### Elasticsearch

[](#elasticsearch)

To profile Elasticsearch requests, you only need to decorate the Elasticsearch client with the ClientDecorator:

```
$elasticsearch = new Elasticsearch\Client(['your' => 'config']);
$client = new \Fabfuel\Prophiler\Decorator\Elasticsearch\ClientDecorator($client, $profiler);
```

Tips
----

[](#tips)

### Record session writing

[](#record-session-writing)

To record session writing, you can commit (this is also known as `session_write_close()`) the session before rendering the toolbar

```
session_commit();
```

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity43

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 73.8% 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/a2b9d982a819ceadbc557e2da82bde0dab47c37ea73728ad93239ec7fe99e54c?d=identicon)[davihu](/maintainers/davihu)

---

Top Contributors

[![fabfuel](https://avatars.githubusercontent.com/u/1582291?v=4)](https://github.com/fabfuel "fabfuel (197 commits)")[![potfur](https://avatars.githubusercontent.com/u/1244857?v=4)](https://github.com/potfur "potfur (37 commits)")[![mdular](https://avatars.githubusercontent.com/u/1701626?v=4)](https://github.com/mdular "mdular (16 commits)")[![kscr-rocket](https://avatars.githubusercontent.com/u/1768816?v=4)](https://github.com/kscr-rocket "kscr-rocket (5 commits)")[![shochdoerfer](https://avatars.githubusercontent.com/u/596449?v=4)](https://github.com/shochdoerfer "shochdoerfer (4 commits)")[![davihu](https://avatars.githubusercontent.com/u/11491151?v=4)](https://github.com/davihu "davihu (2 commits)")[![ogarbe](https://avatars.githubusercontent.com/u/1395245?v=4)](https://github.com/ogarbe "ogarbe (2 commits)")[![lajosbencz](https://avatars.githubusercontent.com/u/8420835?v=4)](https://github.com/lajosbencz "lajosbencz (1 commits)")[![CyberBLN](https://avatars.githubusercontent.com/u/378377?v=4)](https://github.com/CyberBLN "CyberBLN (1 commits)")[![bryant1410](https://avatars.githubusercontent.com/u/3905501?v=4)](https://github.com/bryant1410 "bryant1410 (1 commits)")[![scrutinizer-auto-fixer](https://avatars.githubusercontent.com/u/6253494?v=4)](https://github.com/scrutinizer-auto-fixer "scrutinizer-auto-fixer (1 commits)")

### Embed Badge

![Health badge](/badges/davihu-prophiler/health.svg)

```
[![Health](https://phpackages.com/badges/davihu-prophiler/health.svg)](https://phpackages.com/packages/davihu-prophiler)
```

###  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)
