PHPackages                             soyuka/php-to-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. [Validation &amp; Sanitization](/categories/validation)
4. /
5. soyuka/php-to-json-schema

ActiveLibrary[Validation &amp; Sanitization](/categories/validation)

soyuka/php-to-json-schema
=========================

Generate a JSON schema from a PHP entity

1.0.1(9y ago)19.5k1MITPHPPHP &gt;=7.0

Since Jan 11Pushed 9y ago1 watchersCompare

[ Source](https://github.com/soyuka/php-to-json-schema)[ Packagist](https://packagist.org/packages/soyuka/php-to-json-schema)[ Docs](https://dunglas.fr)[ RSS](/packages/soyuka-php-to-json-schema/feed)WikiDiscussions master Synced 2mo ago

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

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

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

Creates a JSON Schema from a PHP entity. Useful to ensure that a given JSON document will be deserialized properly in an object graph.

[![Build Status](https://camo.githubusercontent.com/5a6ec9fe54098c8d5f573e24b9335aa4dff0b31198ee4fa1b218dafb17c7b1b4/68747470733a2f2f7472617669732d63692e6f72672f64756e676c61732f7068702d746f2d6a736f6e2d736368656d612e737667)](https://travis-ci.org/dunglas/php-to-json-schema)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/6488c39e65c2d43b3b19c4f2aa5292d64a2e3304113b9b276062e19de4ac3bd7/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f64756e676c61732f7068702d746f2d6a736f6e2d736368656d612f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/dunglas/php-to-json-schema/?branch=master)[![SensioLabsInsight](https://camo.githubusercontent.com/d1a5e8c7515e83fb4989dd9f9e05a851233e90bdfcf314b60479973363c67257/68747470733a2f2f696e73696768742e73656e73696f6c6162732e636f6d2f70726f6a656374732f33313562636630302d326137642d343138352d393239302d6330326336376337333164372f6d696e692e706e67)](https://insight.sensiolabs.com/projects/315bcf00-2a7d-4185-9290-c02c67c731d7)

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

[](#installation)

Use [https://getcomposer.org](Composer) to install the library:

```
composer require dunglas/php-to-json-schema

```

Usage
-----

[](#usage)

```
use Dunglas\PhpToJsonSchema\Generator;
use Symfony\Component\PropertyInfo\Extractor\ReflectionExtractor;
use Symfony\Component\PropertyInfo\PropertyInfoExtractor;

class MyClass
{
    private $foo;
    private $bar;

    public function setFoo(string $foo)
    {
        $this->foo = $foo;
    }

    public function setBar(float $bar = null)
    {
        $this->bar = $bar;
    }

    // ...
}

$reflectionExtractor = new ReflectionExtractor();
$propertyInfoExtractor = new PropertyInfoExtractor([$reflectionExtractor], [$reflectionExtractor], [], [$reflectionExtractor]);

$this->generator = new Generator($propertyInfoExtractor);
echo json_encode($generator->generate(MyClass::class));
```

Credits
-------

[](#credits)

Created by [Kévin Dunglas](https://dunglas.fr).

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity20

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

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

Total

2

Last Release

3386d ago

### Community

Maintainers

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

---

Top Contributors

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

---

Tags

phpjsonvalidationjson-schemaentity

### Embed Badge

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

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

###  Alternatives

[opis/json-schema

Json Schema Validator for PHP

64236.9M186](/packages/opis-json-schema)[evaisse/php-json-schema-generator

A JSON Schema Generator.

20298.5k1](/packages/evaisse-php-json-schema-generator)[fab2s/dt0

Immutable DTOs with bidirectional casting. No framework required. 8x faster than the alternative.

101.6k1](/packages/fab2s-dt0)

PHPackages © 2026

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