PHPackages                             b2pweb/bdf-prime-analyzer - 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. b2pweb/bdf-prime-analyzer

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

b2pweb/bdf-prime-analyzer
=========================

Analyze queries generated by Prime ORM and dump unsafe or not optimized queries

v1.0.6(7mo ago)04.8k↓52.2%[1 PRs](https://github.com/b2pweb/bdf-prime-analyzer/pulls)1MITPHPPHP ~7.1 || ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0 || ~8.5.0CI passing

Since Dec 14Pushed 7mo ago2 watchersCompare

[ Source](https://github.com/b2pweb/bdf-prime-analyzer)[ Packagist](https://packagist.org/packages/b2pweb/bdf-prime-analyzer)[ RSS](/packages/b2pweb-bdf-prime-analyzer/feed)WikiDiscussions 1.0 Synced yesterday

READMEChangelogDependencies (4)Versions (10)Used By (1)

Prime Analyzer
==============

[](#prime-analyzer)

[![build](https://github.com/b2pweb/bdf-prime-analyzer/actions/workflows/php.yml/badge.svg)](https://github.com/b2pweb/bdf-prime-analyzer/actions/workflows/php.yml)[![codecov](https://camo.githubusercontent.com/0c57717371673bedcf3137bcb0eaa0697aed3b16d60d37ce8af824c457d2f928/68747470733a2f2f636f6465636f762e696f2f6769746875622f6232707765622f6264662d7072696d652d616e616c797a65722f6272616e63682f322e302f67726170682f62616467652e7376673f746f6b656e3d564f4653504557594b58)](https://app.codecov.io/github/b2pweb/bdf-prime-analyzer)[![Packagist Version](https://camo.githubusercontent.com/6e24e3bbd46c8ee95b05be2d98c8ede17da2b39024e67d4e4b8fa645d658bb77/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6232707765622f6264662d7072696d652d616e616c797a65722e737667)](https://packagist.org/packages/b2pweb/bdf-prime-analyzer)[![Total Downloads](https://camo.githubusercontent.com/be2f877e50916d56ac5bd2256d6f8365ad44919411d3c80173f13b45a2b0d112/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6232707765622f6264662d7072696d652d616e616c797a65722e737667)](https://packagist.org/packages/b2pweb/bdf-prime-analyzer)[![Type Coverage](https://camo.githubusercontent.com/d863396d373b4afce0aab6c158362cbb8cd238cac7072764f0f5b9fbed2c1374/68747470733a2f2f73686570686572642e6465762f6769746875622f6232707765622f6264662d7072696d652d616e616c797a65722f636f7665726167652e737667)](https://shepherd.dev/github/b2pweb/bdf-prime-analyzer)

Analyse executed queries during runtime to report suspicious queries or optimisations tips.

Usage
-----

[](#usage)

Install using composer

```
composer require --dev b2p/bdf-prime-analyzer

```

Register on unit test case

```
    public static function createApplication()
    {
        $app = require __DIR__ . '/../../app/application.php';
        // ...
        $app->register(new \Bdf\Prime\Analyzer\PrimeAnalyzerServiceProvider([
            'ignoredPath' => [dirname(__DIR__)],
            'dumpFormats' => [
                new \Bdf\Prime\Analyzer\Testing\DumpFormat\HtmlDumpFormat(__DIR__.'/prime-report.html'),
                new \Bdf\Prime\Analyzer\Testing\DumpFormat\ConsoleDumpFormat(),
            ],
            'ignoredAnalysis' => [],
        ]));

        // ...

        return $app;
    }
```

To ignore analysis on a single query, simple add the `@prime-analyzer-ignore [analisys]` tag on the execute line.

```
$credentials = $device->relation('credentials')->first(); // @prime-analyzer-ignore optimisation sort
```

You can also ignore analysis globally on the entity, using the docblock of the Mapper class. Unlike the query inline ignore, parameters can be set to ignore only the listed attributes.

```
/**
 * Mapper for TourOperation
 *
 * @prime-analyzer-ignore sort position
 * @prime-analyzer-ignore not_declared my_raw_attribute
 * @prime-analyzer-ignore index
 */
class TourOperationMapper extends Mapper
{
    // ...
}
```

Options
-------

[](#options)

Available options to set on the service provider registration :

- **ignoredPath** : List of path to ignore on the query analysis. For example the tests directory.
- **ignoredAnalysis** : List of analysis to ignore. See AnalysisTypes. AnalysisTypes::optimisations() can be used to only report dangerous queries.
- **dumpFormats** : List of DumpFormatInterface instances.
    - ConsoleDumpFormat : for dump in console after the end of tests
    - HtmlDumpFormat : for dump into an HTML file
- **register** : Set false to disable reporting

Analysis
--------

[](#analysis)

- **like** : Analyse the LIKE filters, and dump values without wildcard \_ or %.
- **index** : Dump queries without any indexes. Queries with at least one relation or join are ignored.
- **not\_declared** : Dump use of undeclared attributes (i.e. attributes not in mapper).
- **sort** : Dump queries with an ORDER clause on non-indexed attribute. You may ignore those reports if the returned set is small.
- **or** : Dump queries with an OR clause not nested into parenthesis.
- **optimisation** : Dump queries which can be optimised using KeyValueQuery or findById. See limitations for more information.
- **relation\_distant\_key** : Dump queries using the distant key of a relation instead of the local key. This cause a useless join. Do not handle "through" relations.
- **write** : Dump invalid update or insert queries. Analyse undeclared attributes and values types.
- **n+1** : Dump N+1 or loop queries. To raise an N+1, the queries must be at least called twice with the same stacktrace. Ignore only if the loop is desired (like walker).

Limitations
-----------

[](#limitations)

- Do not handle raw expressions or join.
- **optimisation** may generate report on relation query, which cannot be fixed, and should be ignored.
- **n+1** may report a false positive in case of load() two relations on same entity (ex: $orderCustomer.load(\['lading', 'delivery'\])).
- Always verify indexes. The **index** analysis do not replace an **EXPLAIN**.

###  Health Score

46

—

FairBetter than 92% of packages

Maintenance64

Regular maintenance activity

Popularity23

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity73

Established project with proven stability

 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

Every ~180 days

Recently: every ~103 days

Total

9

Last Release

220d ago

Major Versions

v1.0.3 → 2.0.x-dev2024-10-11

PHP version history (7 changes)v1.0.0PHP ~7.1 || ~8.0.0

v1.0.1PHP ~7.1 || ~8.0.0 || ~8.1.0

v1.0.2PHP ~7.1 || ~8.0.0 || ~8.1.0 || ~8.2.0

v1.0.3PHP ~7.1 || ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0

2.0.x-devPHP ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0

v1.0.4PHP ~7.1 || ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0

v1.0.6PHP ~7.1 || ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0 || ~8.5.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/1c87e81e7c2f228f5f9b346e86776c8a8740a9f8eb39d710d1de136dbd7c75a3?d=identicon)[Johnmeurt](/maintainers/Johnmeurt)

---

Top Contributors

[![vincent4vx](https://avatars.githubusercontent.com/u/1770818?v=4)](https://github.com/vincent4vx "vincent4vx (52 commits)")

---

Tags

ormanalyzerprime

###  Code Quality

TestsPHPUnit

Static AnalysisPsalm

Type Coverage Yes

### Embed Badge

![Health badge](/badges/b2pweb-bdf-prime-analyzer/health.svg)

```
[![Health](https://phpackages.com/badges/b2pweb-bdf-prime-analyzer/health.svg)](https://phpackages.com/packages/b2pweb-bdf-prime-analyzer)
```

###  Alternatives

[doctrine/orm

Object-Relational-Mapper for PHP

10.2k300.5M7.5k](/packages/doctrine-orm)[doctrine/doctrine-bundle

Symfony DoctrineBundle

4.8k254.4M4.1k](/packages/doctrine-doctrine-bundle)[doctrine/persistence

The Doctrine Persistence project is a set of shared interfaces and functionality that the different Doctrine object mappers share.

4.0k304.4M1.0k](/packages/doctrine-persistence)[gedmo/doctrine-extensions

Doctrine behavioral extensions

4.1k124.6M430](/packages/gedmo-doctrine-extensions)[illuminate/database

The Illuminate Database package.

2.8k54.9M11.6k](/packages/illuminate-database)[beberlei/doctrineextensions

A set of extensions to Doctrine 2 that add support for additional query functions available in MySQL, Oracle, PostgreSQL and SQLite.

2.1k79.7M184](/packages/beberlei-doctrineextensions)

PHPackages © 2026

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