PHPackages                             wwwision/jsonschema - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. wwwision/jsonschema

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

wwwision/jsonschema
===================

PHP Classes to represent JSON schema, see https://json-schema.org/

1.0.1(1y ago)07.8k1MITPHPPHP &gt;=8.1CI passing

Since Apr 10Pushed 1y ago1 watchersCompare

[ Source](https://github.com/bwaidelich/jsonschema)[ Packagist](https://packagist.org/packages/wwwision/jsonschema)[ GitHub Sponsors](https://github.com/sponsors/bwaidelich)[ Fund](https://www.paypal.me/bwaidelich)[ RSS](/packages/wwwision-jsonschema/feed)WikiDiscussions main Synced 2d ago

READMEChangelog (2)Dependencies (5)Versions (4)Used By (1)

JSON Schema
===========

[](#json-schema)

PHP Classes to represent JSON Schemas, see [JSON Schema](https://json-schema.org/)

Usage
-----

[](#usage)

This package can be installed via [composer](https://getcomposer.org):

```
composer require wwwision/jsonschema
```

With that, you can define a JSON Schema in PHP:

```
$schema = new ObjectSchema(
    title: 'Product',
    description: 'A product in the catalog',
    properties: ObjectProperties::create(
        id: new StringSchema(
            title: 'ID',
            description: 'The unique identifier for a product',
            format: StringFormat::uuid,
        ),
        title: new StringSchema(
            title: 'Product title',
            description: 'The name of the product',
        ),
        available: new BooleanSchema(
            title: 'Whether the product is available',
        ),
        price: new NumberSchema(
            title: 'Price',
            description: 'The price of the product',
            default: 0.0,
            minimum: 0.0,
        )
    )
);

$expected =
