2017 © Pedro Peláez
 

library php-to-json-schema

Generate a JSON schema from a PHP entity

image

dunglas/php-to-json-schema

Generate a JSON schema from a PHP entity

  • Tuesday, July 3, 2018
  • by dunglas
  • Repository
  • 2 Watchers
  • 25 Stars
  • 549 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 3 Forks
  • 1 Open issues
  • 3 Versions
  • 58 % Grown

The README.md

PHP to JSON Schema

This library is deprecated, use API Platform JSON Schema instead., (*1)

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

Build Status Scrutinizer Code Quality SensioLabsInsight, (*3)

Installation

Use https://getcomposer.org to install the library:, (*4)

composer require dunglas/php-to-json-schema

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

Created by Kévin Dunglas., (*5)

The Versions

03/07 2018

dev-dunglas-symfony4

dev-dunglas-symfony4 https://dunglas.fr

Generate a JSON schema from a PHP entity

  Sources   Download

MIT

The Requires

 

The Development Requires

php json validation entity json schema

14/02 2018

dev-master

9999999-dev https://dunglas.fr

Generate a JSON schema from a PHP entity

  Sources   Download

MIT

The Requires

 

The Development Requires

php json validation entity json schema

11/01 2016

v0.1.0

0.1.0.0 https://dunglas.fr

Generate a JSON schema from a PHP entity

  Sources   Download

MIT

The Requires

 

The Development Requires

php json validation entity json schema