PHPackages                             sentinelphp/schema - 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. [API Development](/categories/api)
4. /
5. sentinelphp/schema

ActiveLibrary[API Development](/categories/api)

sentinelphp/schema
==================

JSON Schema generation, merging, and validation library

v1.0.1(2mo ago)001GPL-3.0-or-laterPHP &gt;=8.2

Since Apr 27Compare

[ Source](https://github.com/SentinelPHP/Schema)[ Packagist](https://packagist.org/packages/sentinelphp/schema)[ Docs](https://github.com/SentinelPHP/schema)[ RSS](/packages/sentinelphp-schema/feed)WikiDiscussions Synced 3w ago

READMEChangelogDependencies (3)Versions (3)Used By (1)

Sentinel Schema
===============

[](#sentinel-schema)

[![Latest Version](https://camo.githubusercontent.com/66af132f9de618a6ecf46a953859a88f25b38a2cd738e45370ac24843b12c8e8/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f73656e74696e656c7068702f736368656d612e737667)](https://packagist.org/packages/sentinelphp/schema)[![License](https://camo.githubusercontent.com/33bfcd31eff12083e63a9e60f8b13e1f02609bc3d9a3ade6a13d76f6dbe3d14c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f73656e74696e656c7068702f736368656d612e737667)](https://github.com/SentinelPHP/schema/blob/main/LICENSE)

JSON Schema generation, merging, and validation library.

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

[](#installation)

```
composer require sentinelphp/schema
```

Features
--------

[](#features)

- **Generate** JSON Schema from sample data
- **Merge** multiple schemas together
- **Validate** data against schemas

Usage
-----

[](#usage)

### Schema Generation

[](#schema-generation)

```
use SentinelPHP\Schema\Generator;
use SentinelPHP\Schema\Config\GeneratorConfig;

$generator = new Generator();

$data = [
    'id' => 123,
    'name' => 'John Doe',
    'email' => 'john@example.com',
    'created_at' => '2024-01-15T10:30:00Z',
];

$schema = $generator->generate($data);
// Returns JSON Schema with inferred types and formats
```

### Schema Merging

[](#schema-merging)

```
use SentinelPHP\Schema\Merger;

$merger = new Merger();

$schema1 = ['type' => 'object', 'properties' => ['id' => ['type' => 'integer']]];
$schema2 = ['type' => 'object', 'properties' => ['name' => ['type' => 'string']]];

$merged = $merger->merge($schema1, $schema2);
// Combines properties, widens types, intersects required fields
```

### Schema Validation

[](#schema-validation)

```
use SentinelPHP\Schema\Validator;

$validator = new Validator();

$schema = [
    'type' => 'object',
    'properties' => [
        'email' => ['type' => 'string', 'format' => 'email'],
    ],
    'required' => ['email'],
];

$result = $validator->validate(['email' => 'invalid'], $schema);

if (!$result->isValid()) {
    foreach ($result->getErrors() as $error) {
        echo $error->path . ': ' . $error->message;
    }
}
```

### Partial Validation

[](#partial-validation)

Validate only the fields present in the payload:

```
$result = $validator->validatePartial($partialData, $schema);
```

Configuration
-------------

[](#configuration)

```
use SentinelPHP\Schema\Config\GeneratorConfig;

$config = new GeneratorConfig(
    strictMode: true,           // Require all observed fields
    nullableFields: false,      // Don't allow null by default
    additionalProperties: false // Disallow extra properties
);

$generator = new Generator();
$schema = $generator->generate($data, $config);
```

License
-------

[](#license)

GPL v3 — see LICENSE for details

###  Health Score

36

—

LowBetter than 79% of packages

Maintenance83

Actively maintained with recent releases

Popularity0

Limited adoption so far

Community5

Small or concentrated contributor base

Maturity47

Maturing project, gaining track record

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

88d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/3542330?v=4)[Tommy Lynge Jørgensen](/maintainers/TLyngeJ)[@TLyngeJ](https://github.com/TLyngeJ)

---

Tags

apischemavalidationjson-schema

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[orisai/object-mapper

Raw data mapping to validated objects

1133.7k2](/packages/orisai-object-mapper)[adrenalinkin/swagger-resolver-bundle

Provides possibility for validate data according to Swagger documentation

1013.3k](/packages/adrenalinkin-swagger-resolver-bundle)

PHPackages © 2026

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