PHPackages                             dunglas/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. dunglas/php-to-json-schema

Abandoned → [api-platform/core](/?search=api-platform%2Fcore)ArchivedLibrary[Validation &amp; Sanitization](/categories/validation)

dunglas/php-to-json-schema
==========================

Generate a JSON schema from a PHP entity

v0.1.0(10y ago)302.1k3[2 PRs](https://github.com/dunglas/php-to-json-schema/pulls)MITPHPPHP &gt;=7.0

Since Jan 11Pushed 4y ago1 watchersCompare

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

READMEChangelog (1)Dependencies (2)Versions (3)Used By (0)

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

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

**This library is deprecated, use [API Platform JSON Schema](https://api-platform.com/docs/core/json-schema/) instead.**

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]);

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

Credits
-------

[](#credits)

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

###  Health Score

29

—

LowBetter than 63% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity26

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor1

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

3722d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/57224?v=4)[Kévin Dunglas](/maintainers/dunglas)[@dunglas](https://github.com/dunglas)

---

Top Contributors

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

---

Tags

jsonjson-schemaphpphpjsonvalidationjson-schemaentity

### Embed Badge

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

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

###  Alternatives

[opis/json-schema

Json Schema Validator for PHP

64135.0M145](/packages/opis-json-schema)[evaisse/php-json-schema-generator

A JSON Schema Generator.

18293.6k1](/packages/evaisse-php-json-schema-generator)

PHPackages © 2026

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