PHPackages                             forrest79/phpgsql-tracy - 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. [Database &amp; ORM](/categories/database)
4. /
5. forrest79/phpgsql-tracy

ActiveLibrary[Database &amp; ORM](/categories/database)

forrest79/phpgsql-tracy
=======================

Use PhPgSql with Tracy from Nette Framework.

v2.0.1(7mo ago)05[1 issues](https://github.com/forrest79/phpgsql-tracy/issues)BSD-3-ClausePHPPHP ^8.3CI passing

Since Oct 21Pushed 7mo ago1 watchersCompare

[ Source](https://github.com/forrest79/phpgsql-tracy)[ Packagist](https://packagist.org/packages/forrest79/phpgsql-tracy)[ RSS](/packages/forrest79-phpgsql-tracy/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (8)Versions (56)Used By (0)

PhPgSql - Tracy
===============

[](#phpgsql---tracy)

[![Latest Stable Version](https://camo.githubusercontent.com/44f7a876e581d5dcd3124e93e5ad52de0709e2f5b3fd7a94086efeb77dba4b68/68747470733a2f2f706f7365722e707567782e6f72672f666f727265737437392f7068706773716c2d74726163792f76)](//packagist.org/packages/forrest79/phpgsql-tracy)[![Monthly Downloads](https://camo.githubusercontent.com/24aa40c4d9df60db2f3e46d0895e122511265feebd32c34d319286efc752fa17/68747470733a2f2f706f7365722e707567782e6f72672f666f727265737437392f7068706773716c2d74726163792f642f6d6f6e74686c79)](//packagist.org/packages/forrest79/phpgsql-tracy)[![License](https://camo.githubusercontent.com/6028da188169168dfcd8b8860acaf64ed266a3986616781ab1ad92730a04f23c/68747470733a2f2f706f7365722e707567782e6f72672f666f727265737437392f7068706773716c2d74726163792f6c6963656e7365)](//packagist.org/packages/forrest79/phpgsql-tracy)[![Build](https://github.com/forrest79/phpgsql-tracy/actions/workflows/build.yml/badge.svg?branch=master)](https://github.com/forrest79/phpgsql-tracy/actions/workflows/build.yml)

- [PhPgSql](https://github.com/forrest79/phpgsql)
- [Tracy](https://tracy.nette.org/cs/)

Use PhPgSql with Tracy from Nette Framework.

Introduction
------------

[](#introduction)

Tracy bar panel to show queries executed in your database and bluescreen extension to show failed database query.

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

[](#installation)

The recommended way to install PhPgSql - Tracy is through Composer:

```
composer require forrest79/phpgsql-nette
```

Using
-----

[](#using)

### Bar panel

[](#bar-panel)

Bar panel will show all queries executed in your database. You copy query to the clipboard, mark long run queries, mark repeated queries, show notices and non parsed columns.

You can add the panel for each database connection:

```
$tracyBar = Tracy\Debugger::getBar(); // or instance get from DI container or somewhere else
$connection = new Forrest79\PhPgSql\Db\Connection(); // or instance get from DI container or somewhere else
$queryDumper = new PhPgSql\Tracy\QueryDumpers\SqlFormatter(); // or some other query dumper
$name = 'Main connection'; // just to recognize two different bars

$barPanel = PhPgSql\Tracy\BarPanel::initialize(
    $tracyBar,
    $connection,
    $queryDumper,
    $name,
    explain: false, // when true, explain is execute and show for all queries
    notices: false, // when true, notices are get from the database and show with the queries
    longQueryTimeMs: null, // if you set some value in miliseconds, long running queries will be marked
    detectRepeatingQueries: false, // when true, repeating queries will be detected and marked
    detectNonParsedColumns: false, // when true, non-used columns wil be detected and show for each query
    backtraceContinueIterate: null, // used for detection where the query was executed in the PHP code - callable, more about this later
    showMaxLastQueries: null, // show only last queries, when null - default value of 1000 queries is used, selected value otherwise
);

// To disable bar panel

$barPanel->disable();
```

- bar can be disabled with `disable()` method

### `$backtraceContinueIterate` parameter

[](#backtracecontinueiterate-parameter)

Panel is showing links to the PHP source files, where the query was executed. This is made using PHP function `debug_backtrace()`. This function returns the whole call stack. To get the correct place in the PHP source file, we must ignore some internal library classes where the query is really executed and iterated up to the user code, that run this execution.

Basically, `BarPanel` ignores all classes/function from PhPgSql library to show the most accurate place in the PHP source.

When you use some own custom wrapping objects, you want to ignore it in the call stack as well. You can some callable and pass it to the `$backtraceContinueIterate` Parameter. For example:

```
$backtraceContinueIterate = function (string $class, string $function): bool
{
    return (is_a($class, MyOwn\Database\Repository::class, true) && in_array($function, ['get', 'insert', 'insertReturning', 'multiInsert', 'update', 'updateReturning', 'saveBy', 'delete', 'deleteReturning', 'getNextId'], true))
        || (is_a($class, MyOwn\Database\Transaction::class, true) && in_array($function, ['execute', 'beginSmart', 'commitSmart', 'rollbackSmart'], true))
        || (is_a($class, MyOwn\Database\DbFunction::class, true) && in_array($function, ['fetch', 'run', 'from'], true))
        || (is_a($class, MyOwn\Database\Fluent\Query::class, true) && in_array($function, ['count', 'exists', 'fetchSingleValue'], true));
}
```

### Bluescreen

[](#bluescreen)

Bluescreen should be registered just once (it doesn't matter how many DB connections you have):

```
$tracyBlueScreen = Tracy\Debugger::getBlueScreen(); // or instance get from DI container or somewhere else
$queryDumper = new PhPgSql\Tracy\QueryDumpers\SqlFormatter(); // or some other query dumper
PhPgSql\Tracy\BlueScreenPanel::initialize($tracyBlueScreen, $queryDumper);
```

With this, when some `Forrest79\PhPgSql\Db\Exceptions\QueryException` is thrown, you will see the SQL query and the parameters (and the SQL query with the parameters) on your BlueScreen.

Query dumper
------------

[](#query-dumper)

SQL queries are dumped in `Tracy\Bar` and in `Tracy\BlueScreen` and you can use different dumpers/formatters. Three are included:

- `PhPgSql\Tracy\QueryDumpers\NullDumper` - show SQL query as it is
- `PhPgSql\Tracy\QueryDumpers\Basic` - highlight and format SQL query with basic internal formatter
- `PhPgSql\Tracy\QueryDumpers\SqlFormatter` - highlight and format SQL query with [Doctrine\\Sql-Formatter](https://github.com/doctrine/sql-formatter), `Doctrine\Sql-Formatter` must be is installed (`composer require doctrine/sql-formatter --dev`)

Or you can use your own query dumper, just create a class-extending abstract class `PhPgSql\Tracy\QueryDumper`.

###  Health Score

46

—

FairBetter than 93% of packages

Maintenance65

Regular maintenance activity

Popularity4

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity90

Battle-tested with a long release history

 Bus Factor1

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

Every ~47 days

Recently: every ~70 days

Total

55

Last Release

211d ago

Major Versions

v0.10.0 → v1.0.02021-07-23

v1.6.5 → v2.0.02025-10-01

PHP version history (6 changes)v0.1.0PHP &gt;=7.1

v0.10.0PHP ^7.1 | ^8.0

v1.2.0PHP ^7.2 | ^8.0

v1.4.0PHP ^8.0

v1.5.0PHP ^8.1

v2.0.0PHP ^8.3

### Community

Maintainers

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

---

Top Contributors

[![forrest79](https://avatars.githubusercontent.com/u/160766?v=4)](https://github.com/forrest79 "forrest79 (113 commits)")[![h4kuna](https://avatars.githubusercontent.com/u/335722?v=4)](https://github.com/h4kuna "h4kuna (2 commits)")

---

Tags

nettedatabasepostgresqltracyphpgsql

###  Code Quality

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/forrest79-phpgsql-tracy/health.svg)

```
[![Health](https://phpackages.com/badges/forrest79-phpgsql-tracy/health.svg)](https://phpackages.com/packages/forrest79-phpgsql-tracy)
```

###  Alternatives

[nette/database

💾 Nette Database: layer with a familiar PDO-like API but much more powerful. Building queries, advanced joins, drivers for MySQL, PostgreSQL, SQLite, MS SQL Server and Oracle.

5656.7M234](/packages/nette-database)[amphp/postgres

Asynchronous PostgreSQL client for Amp.

110509.8k27](/packages/amphp-postgres)[sad_spirit/pg_wrapper

Converter of complex PostgreSQL types and an OO wrapper for PHP's pgsql extension

2211.2k2](/packages/sad-spirit-pg-wrapper)[davmixcool/php-dbcloud

Easily backup PostgreSql or MySql database to the cloud

111.5k](/packages/davmixcool-php-dbcloud)

PHPackages © 2026

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