PHPackages                             koriym/ext-json-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. [Utility &amp; Helpers](/categories/utility)
4. /
5. koriym/ext-json-schema

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

koriym/ext-json-schema
======================

Adapter for using PECL json\_schema extension with jsonrainbow/json-schema API compatibility

1.x-dev(4mo ago)00[2 issues](https://github.com/koriym/ext-json-schema/issues)MITCPHP ^8.1CI passing

Since Jan 6Pushed 3mo agoCompare

[ Source](https://github.com/koriym/ext-json-schema)[ Packagist](https://packagist.org/packages/koriym/ext-json-schema)[ Docs](https://github.com/koriym/ext-json-schema)[ RSS](/packages/koriym-ext-json-schema/feed)WikiDiscussions 1.x Synced 1mo ago

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

ext-json-schema
===============

[](#ext-json-schema)

High-performance JSON Schema validator for PHP as a PECL extension.

[![Build and Test PHP Extension](https://github.com/koriym/ext-json-schema/actions/workflows/build.yml/badge.svg?branch=1.x)](https://github.com/koriym/ext-json-schema/actions/workflows/build.yml)

Features
--------

[](#features)

- **JSON Schema Draft-04/06/07** support
- **2178 tests passed** from [JSON Schema Test Suite](https://github.com/json-schema-org/JSON-Schema-Test-Suite)
- **[jsonrainbow/json-schema](https://github.com/jsonrainbow/json-schema) compatible** API
- Native C implementation for performance

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

[](#requirements)

- PHP 8.1+

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

[](#installation)

### PECL Extension

[](#pecl-extension)

```
git clone https://github.com/koriym/ext-json-schema.git
cd ext-json-schema
phpize
./configure
make
make install
```

Add to your `php.ini`:

```
extension=json_schema.so
```

### PHP Adapter (Optional)

[](#php-adapter-optional)

For `ValidatorAdapter` that provides jsonrainbow/json-schema compatible API:

```
composer require koriym/ext-json-schema:dev-1.x
```

Usage
-----

[](#usage)

### Procedural API

[](#procedural-api)

```
$data = ['name' => 'John', 'age' => 30];
$schema = [
    'type' => 'object',
    'properties' => [
        'name' => ['type' => 'string'],
        'age' => ['type' => 'integer', 'minimum' => 0]
    ],
    'required' => ['name']
];

if (json_schema_validate($data, $schema)) {
    echo "Valid!";
}
```

### OOP API

[](#oop-api)

```
$validator = new JsonSchema\Validator();
$validator->validate($data, $schema);

if ($validator->isValid()) {
    echo "Valid!";
} else {
    print_r($validator->getErrors());
}
```

### jsonrainbow/json-schema Compatible Adapter

[](#jsonrainbowjson-schema-compatible-adapter)

For projects using [jsonrainbow/json-schema](https://github.com/jsonrainbow/json-schema), use `ValidatorAdapter` for a drop-in replacement:

```
use JsonSchema\ValidatorAdapter;

$validator = new ValidatorAdapter();
$validator->validate($data, $schema);

// Same API as jsonrainbow/json-schema
$validator->isValid();
$validator->getErrors();    // Compatible error format
$validator->numErrors();
$validator->reset();
```

Error Format
------------

[](#error-format)

Errors match jsonrainbow/json-schema format:

```
[
    'property'   => 'user.email',     // Dot notation path
    'pointer'    => '/user/email',    // JSON Pointer
    'message'    => 'Type mismatch',
    'constraint' => 'type',           // Constraint name
    'context'    => 1                 // ERROR_DOCUMENT_VALIDATION
]
```

Supported Keywords
------------------

[](#supported-keywords)

CategoryKeywordsType`type`String`minLength`, `maxLength`, `pattern`, `format`Number`minimum`, `maximum`, `exclusiveMinimum`, `exclusiveMaximum`, `multipleOf`Array`items`, `additionalItems`, `minItems`, `maxItems`, `uniqueItems`, `contains`Object`properties`, `additionalProperties`, `required`, `minProperties`, `maxProperties`, `propertyNames`, `dependencies`Combinators`allOf`, `anyOf`, `oneOf`, `not`Conditional`if`, `then`, `else`Reference`$ref`, `definitions`, `$defs`Other`enum`, `const`Quality Assurance
-----------------

[](#quality-assurance)

This extension was implemented with [Claude Code](https://claude.ai/code) (Opus 4.5) and undergoes rigorous testing:

TestCoverage**JSON Schema Test Suite**2178/2178 tests passed (100%)**PHPT Unit Tests**15 tests covering all features**API Compatibility Tests**30 PHPUnit tests for jsonrainbow compatibility**Memory Leak Detection**Valgrind + PHP's built-in leak detector**Multi-version Testing**PHP 8.1, 8.2, 8.3, 8.4, 8.5### Memory Safety

[](#memory-safety)

```
# Run with Valgrind memory check
USE_ZEND_ALLOC=0 ZEND_DONT_UNLOAD_MODULES=1 \
make test TESTS=tests/*.phpt TEST_PHP_ARGS="-m"

# Result: Tests leaked: 0 (0.0%)
```

### Continuous Integration

[](#continuous-integration)

All tests run automatically on every push via GitHub Actions, including:

- Compilation on multiple PHP versions
- Full test suite execution
- Memory leak detection with Valgrind

License
-------

[](#license)

MIT

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance78

Regular maintenance activity

Popularity0

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity33

Early-stage or recently created project

 Bus Factor1

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

Unknown

Total

1

Last Release

132d ago

### Community

Maintainers

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

---

Top Contributors

[![koriym](https://avatars.githubusercontent.com/u/529021?v=4)](https://github.com/koriym "koriym (51 commits)")[![claude](https://avatars.githubusercontent.com/u/81847?v=4)](https://github.com/claude "claude (7 commits)")

---

Tags

json-schemapecl

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/koriym-ext-json-schema/health.svg)

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

PHPackages © 2026

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