2017 © Pedro Peláez
 

library php-to-json-schema

Generate a JSON schema from a PHP entity

image

soyuka/php-to-json-schema

Generate a JSON schema from a PHP entity

  • Tuesday, January 31, 2017
  • by soyuka
  • Repository
  • 1 Watchers
  • 0 Stars
  • 161 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 4 Forks
  • 0 Open issues
  • 3 Versions
  • 104 % Grown

The README.md

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., (*1)

Build Status Scrutinizer Code Quality SensioLabsInsight, (*2)

Installation

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

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

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

Credits

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

The Versions

31/01 2017

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

31/01 2017

1.0.1

1.0.1.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

11/01 2016

1.0.0

1.0.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