wwwision/types-jsonschema

Generator for JSON Schema files from PHP classes, see https://json-schema.org/

Maintainers

👁 bwaidelich

Package info

github.com/bwaidelich/types-jsonschema

pkg:composer/wwwision/types-jsonschema

Fund package maintenance!

bwaidelich

Paypal

Statistics

Installs: 10 322

Dependents: 1

Suggesters: 1

Stars: 1

Open Issues: 1

2.1.0 2025-08-07 19:46 UTC

Requires

Requires (Dev)

Suggests

None

Provides

None

Conflicts

None

Replaces

None

MIT d8f9c35e2de0e605c364e5ddc953cd31f5fd4e5e

  • bwaidelich <b.waidelich.woop@wwwision.de>

This package is auto-updated.

Last update: 2026-06-07 21:27:27 UTC


README

Integration for the wwwision/types package that allows to generate JSON Schema files from PHP code

Usage

This package can be installed via composer:

composer require wwwision/types-jsonschema

With that, you can create JSON Schema from PHP classes:

class Contact {
 public function __construct(public string $name, public int $age) {}
}

$schema = (new JsonSchemaGenerator())->fromClass(Contact::class);

$expected = <<<JSON
{
 "type": "object",
 "properties": {
 "name": {
 "type": "string"
 },
 "age": {
 "type": "integer"
 }
 },
 "additionalProperties": false,
 "required": [
 "name",
 "age"
 ]
}
JSON;

assert(json_encode($schema, JSON_PRETTY_PRINT) === $expected);

Advanced schemas

All attributes of the wwwision/types package are supported in order to create sophisticated schemas.