PHPackages                             open-code-modeling/json-schema-to-php - 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. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. open-code-modeling/json-schema-to-php

ActiveLibrary[Parsing &amp; Serialization](/categories/parsing)

open-code-modeling/json-schema-to-php
=====================================

Parses JSON schema files and provides an API to easily generate code from JSON schema.

0.3.0(5y ago)111.1k↓86.7%1[1 issues](https://github.com/open-code-modeling/json-schema-to-php/issues)2MITPHPPHP ^7.4 || ^8.0CI failing

Since Nov 20Pushed 4y ago2 watchersCompare

[ Source](https://github.com/open-code-modeling/json-schema-to-php)[ Packagist](https://packagist.org/packages/open-code-modeling/json-schema-to-php)[ RSS](/packages/open-code-modeling-json-schema-to-php/feed)WikiDiscussions 0.4.x Synced today

READMEChangelog (4)Dependencies (8)Versions (9)Used By (2)

JSON Schema to PHP
==================

[](#json-schema-to-php)

Parses JSON schema and provides an API to easily generate code from JSON schema.

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

[](#installation)

```
$ composer require open-code-modeling/json-schema-to-php --dev
```

Usage
-----

[](#usage)

Consider you have this JSON schema.

```
{
    "type": "object",
    "required": ["buildingId", "name"],
    "additionalProperties": false,
    "definitions": {
        "name": {
            "type": ["string", "null"]
        }
    },

    "properties": {
        "buildingId": {
            "type": "string",
            "pattern": "^[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12}$"
        },
        "name": {
            "$ref": "#/definitions/name"
        }
    }
}
```

Create a TypeSet definition from parsed JSON:

```
$decodedJson = \json_decode($jsonSchema, true);

$typeSet = Type::fromDefinition($decodedJson);

/** @var ObjectType $type */
$type = $typeSet->first();

$type->additionalProperties(); // false

$properties = $type->properties();

/** @var TypeSet $buildingIdTypeSet */
$buildingIdTypeSet = $properties['buildingId'];

/** @var StringType $buildingId */
$buildingId = $buildingIdTypeSet->first();

$buildingId->name(); // buildingId
$buildingId->type(); // string
$buildingId->pattern(); // ^[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12}$
$buildingId->isRequired(); // true
$buildingId->isNullable(); // false

/** @var TypeSet $nameTypeSet */
$nameTypeSet = $properties['name'];

/** @var ReferenceType $name */
$name = $nameTypeSet->first();

$resolvedTypeSet = $name->resolvedType();

/** @var StringType $resolvedType */
$resolvedType = $resolvedTypeSet->first();

$resolvedType->name(); // name
$resolvedType->type(); // string
$resolvedType->isRequired(); // true
$resolvedType->isNullable(); // true

// ...
```

See `OpenCodeModeling\JsonSchemaToPhp\Type` classes and tests for more information.

###  Health Score

30

—

LowBetter than 62% of packages

Maintenance18

Infrequent updates — may be unmaintained

Popularity25

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 77.1% 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 ~45 days

Recently: every ~74 days

Total

8

Last Release

1736d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/58f3428ea5d86dde45a70842c5228d295ec37a493594d484bf1ed2552e85b791?d=identicon)[sandrokeil](/maintainers/sandrokeil)

---

Top Contributors

[![sandrokeil](https://avatars.githubusercontent.com/u/3597436?v=4)](https://github.com/sandrokeil "sandrokeil (27 commits)")[![open-code-modeling-bot](https://avatars.githubusercontent.com/u/73913277?v=4)](https://github.com/open-code-modeling-bot "open-code-modeling-bot (8 commits)")

---

Tags

jsonjson-schemaparserphpschemaphpjsonschemaparser

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/open-code-modeling-json-schema-to-php/health.svg)

```
[![Health](https://phpackages.com/badges/open-code-modeling-json-schema-to-php/health.svg)](https://phpackages.com/packages/open-code-modeling-json-schema-to-php)
```

###  Alternatives

[corveda/php-sandbox

A PHP library that can be used to run PHP code in a sandboxed environment

23796.2k2](/packages/corveda-php-sandbox)[evaisse/php-json-schema-generator

A JSON Schema Generator.

20316.0k1](/packages/evaisse-php-json-schema-generator)[juststeveking/resume-php

A PHP library for building and working with the JSON resume schema.

1061.1k](/packages/juststeveking-resume-php)

PHPackages © 2026

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