soyuka/php-to-json-schema
Composer 安装命令:
composer require soyuka/php-to-json-schema
包简介
Generate a JSON schema from a PHP entity
README 文档
README
Creates a JSON Schema from a PHP entity. Useful to ensure that a given JSON document will be deserialized properly in an object graph.
Installation
Use https://getcomposer.org to install the library:
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.
统计信息
- 总下载量: 9.51k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 0
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2017-01-31