PHPackages                             sentinelphp/drift - 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. [Logging &amp; Monitoring](/categories/logging)
4. /
5. sentinelphp/drift

ActiveLibrary[Logging &amp; Monitoring](/categories/logging)

sentinelphp/drift
=================

API schema drift detection and classification library

v1.0.1(1mo ago)10GPL-3.0-or-laterPHPPHP &gt;=8.2

Since Apr 27Pushed 1mo agoCompare

[ Source](https://github.com/SentinelPHP/Drift)[ Packagist](https://packagist.org/packages/sentinelphp/drift)[ Docs](https://github.com/SentinelPHP/drift)[ RSS](/packages/sentinelphp-drift/feed)WikiDiscussions main Synced 1w ago

READMEChangelogDependencies (2)Versions (3)Used By (0)

Sentinel Drift
==============

[](#sentinel-drift)

[![Latest Version](https://camo.githubusercontent.com/b9c6d92ba0f0984855582e65689696d5e70dac0f4b69a9bb13e27036fe885a2f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f73656e74696e656c7068702f64726966742e737667)](https://packagist.org/packages/sentinelphp/drift)[![License](https://camo.githubusercontent.com/93b809b59cc1bc920ac3155f402d98cefba1d108801a16a2b586067518e07a9a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f73656e74696e656c7068702f64726966742e737667)](https://github.com/SentinelPHP/drift/blob/main/LICENSE)

API schema drift detection and classification library.

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

[](#installation)

```
composer require sentinelphp/drift
```

Features
--------

[](#features)

- **Detect** differences between expected and actual API responses
- **Classify** drift severity (Info, Warning, Critical)
- **Compare** JSON structures with detailed diff output

Usage
-----

[](#usage)

### Drift Detection

[](#drift-detection)

```
use SentinelPHP\Drift\Detector;
use SentinelPHP\Schema\Validator;

$detector = new Detector(new Validator());

$schema = [
    'type' => 'object',
    'properties' => [
        'id' => ['type' => 'integer'],
        'name' => ['type' => 'string'],
    ],
    'required' => ['id', 'name'],
];

$actualResponse = [
    'id' => '123',  // Type changed: integer → string
    'name' => 'John',
    'extra' => true, // New field added
];

$result = $detector->detect($schema, $actualResponse);

foreach ($result->getDrifts() as $drift) {
    echo sprintf(
        "[%s] %s at %s\n",
        $drift->severity->value,
        $drift->type->value,
        $drift->path
    );
}
```

### Severity Classification

[](#severity-classification)

```
use SentinelPHP\Drift\Classifier;
use SentinelPHP\Drift\Enum\DriftType;
use SentinelPHP\Drift\Enum\DriftSeverity;

$classifier = new Classifier();

// Field removed = Critical
$severity = $classifier->classify(DriftType::FieldRemoved, 'email', null);
// Returns: DriftSeverity::Critical

// Field added = Info
$severity = $classifier->classify(DriftType::FieldAdded, null, 'extra_field');
// Returns: DriftSeverity::Info

// Type changed (object → primitive) = Critical
$severity = $classifier->classify(DriftType::TypeChanged, 'object', 'string');
// Returns: DriftSeverity::Critical
```

### Alert Threshold

[](#alert-threshold)

```
$classifier = new Classifier(defaultThreshold: DriftSeverity::Warning);

// Check if drift should trigger an alert
if ($classifier->shouldAlert($drift->severity)) {
    // Send notification
}

// Override threshold per-check
$classifier->shouldAlert($drift->severity, DriftSeverity::Critical);
```

### JSON Diff

[](#json-diff)

```
use SentinelPHP\Drift\Diff\JsonDiff;

$diff = new JsonDiff();

$expected = ['id' => 1, 'name' => 'John', 'email' => 'john@example.com'];
$actual = ['id' => 1, 'name' => 'Jane', 'phone' => '555-1234'];

$result = $diff->generateDiff($expected, $actual);

echo "Added: " . count($result->added);     // phone
echo "Removed: " . count($result->removed); // email
echo "Changed: " . count($result->changed); // name
```

Drift Types
-----------

[](#drift-types)

TypeDescriptionDefault Severity`FieldRemoved`Required field missingCritical`FieldAdded`New unexpected fieldInfo`TypeChanged`Data type mismatchWarning/Critical`StructureChanged`Array/object structure changedWarningLicense
-------

[](#license)

GPL v3 — see LICENSE for details

###  Health Score

39

—

LowBetter than 84% of packages

Maintenance91

Actively maintained with recent releases

Popularity2

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity47

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 50% 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 ~0 days

Total

2

Last Release

43d ago

### Community

Maintainers

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

---

Top Contributors

[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (1 commits)")[![TLyngeJ](https://avatars.githubusercontent.com/u/3542330?v=4)](https://github.com/TLyngeJ "TLyngeJ (1 commits)")

---

Tags

apimonitoringschemadetectiondrift

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/sentinelphp-drift/health.svg)

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

###  Alternatives

[ohdearapp/ohdear-php-sdk

An SDK to easily work with the Oh Dear API

742.9M16](/packages/ohdearapp-ohdear-php-sdk)[treblle/security-headers

A collection of HTTP middleware classes to improve the security headers in your Laravel application.

9540.7k](/packages/treblle-security-headers)[treblle/treblle-api-tools-laravel

A set of useful tools for building APIs in Laravel.

135.3k1](/packages/treblle-treblle-api-tools-laravel)

PHPackages © 2026

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