PHPackages                             mpyw/unique-violation-detector - 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. mpyw/unique-violation-detector

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

mpyw/unique-violation-detector
==============================

Detect primary/unique key or constraint violation errors from PDOException.

v1.2.0(1y ago)263.9k↓29.4%1MITPHPPHP ^8.2CI passing

Since Nov 26Pushed 5mo ago1 watchersCompare

[ Source](https://github.com/mpyw/unique-violation-detector)[ Packagist](https://packagist.org/packages/mpyw/unique-violation-detector)[ RSS](/packages/mpyw-unique-violation-detector/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (3)Dependencies (1)Versions (5)Used By (1)

Unique Violation Detector [![Build Status](https://github.com/mpyw/unique-violation-detector/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/mpyw/unique-violation-detector/actions) [![Coverage Status](https://camo.githubusercontent.com/1554883b0542eab8316e4744c3e6216404b34ef88c06bab042083373c181a674/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f6d7079772f756e697175652d76696f6c6174696f6e2d6465746563746f722f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/mpyw/unique-violation-detector?branch=master)
===============================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================

[](#unique-violation-detector--)

Detect **primary/unique key or constraint violation** errors from `PDOException`.

Installing
----------

[](#installing)

```
composer require mpyw/unique-violation-detector

```

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

[](#requirements)

PackageVersionPHP`^8.2`Note

Older versions have outdated dependency requirements. If you cannot prepare the latest environment, please refer to past releases.

Supported PDO Drivers
---------------------

[](#supported-pdo-drivers)

DatabaseDriverAuto-DiscoverableMySQL`pdo_mysql`✅PostgreSQL`pdo_pgsql`✅SQLite`pdo_sqlite`✅SQLServer`pdo_sqlsrv`✅SQLServer`pdo_odbc`SQLServer`pdo_dblib`Oracle`pdo_oci`✅Usage
-----

[](#usage)

```
use Mpyw\UniqueViolationDetector\MySQLDetector;

// Explicitly instantiate a detector
$violated = (new MySQLDetector())->uniqueConstraintViolated($exception);
```

```
use Mpyw\UniqueViolationDetector\DetectorDiscoverer;

// Discover a detector from a PDO instance
// (Not available for pdo_odbc and pdo_dblib)
$violated = (new DetectorDiscoverer())
    ->discover($pdo)
    ->uniqueConstraintViolated($exception);
```

###  Health Score

45

—

FairBetter than 93% of packages

Maintenance60

Regular maintenance activity

Popularity31

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity65

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 ~597 days

Total

3

Last Release

440d ago

PHP version history (2 changes)v1.0.0PHP ^7.1 || ^8.0

v1.2.0PHP ^8.2

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1351893?v=4)[mpyw](/maintainers/mpyw)[@mpyw](https://github.com/mpyw)

---

Top Contributors

[![mpyw](https://avatars.githubusercontent.com/u/1351893?v=4)](https://github.com/mpyw "mpyw (10 commits)")

---

Tags

databaseduplicateconstraint

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/mpyw-unique-violation-detector/health.svg)

```
[![Health](https://phpackages.com/badges/mpyw-unique-violation-detector/health.svg)](https://phpackages.com/packages/mpyw-unique-violation-detector)
```

###  Alternatives

[doctrine/dbal

Powerful PHP database abstraction layer (DBAL) with many features for database schema introspection and management.

9.7k578.4M5.6k](/packages/doctrine-dbal)[doctrine/orm

Object-Relational-Mapper for PHP

10.2k285.3M6.2k](/packages/doctrine-orm)[doctrine/doctrine-bundle

Symfony DoctrineBundle

4.8k241.3M3.3k](/packages/doctrine-doctrine-bundle)[doctrine/migrations

PHP Doctrine Migrations project offer additional functionality on top of the database abstraction layer (DBAL) for versioning your database schema and easily deploying changes to it. It is a very easy to use and a powerful tool.

4.8k204.8M440](/packages/doctrine-migrations)[doctrine/data-fixtures

Data Fixtures for all Doctrine Object Managers

2.9k136.1M516](/packages/doctrine-data-fixtures)[robmorgan/phinx

Phinx makes it ridiculously easy to manage the database migrations for your PHP app.

4.5k46.2M405](/packages/robmorgan-phinx)

PHPackages © 2026

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