1. Go to this page and download the library: Download 021/json-schema library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
021 / json-schema example snippets
use O21\JsonSchema\Schema;
use O21\JsonSchema\Enums\Type;
use O21\JsonSchema\Enums\Format;
$schema = new Schema(
schema: 'http://json-schema.org/draft-07/schema#',
type: Type::OBJECT,
properties: [
'name' => new Schema(
type: Type::STRING,
minLength: 1,
maxLength: 255
),
'age' => new Schema(
type: Type::INTEGER,
minimum: 0,
maximum: 150
),
'addresses' => new Schema(
type: Type::ARRAY,
items: new Schema(
type: Type::OBJECT,
properties: [
'street' => new Schema(
type: Type::STRING,
minLength: 1,
maxLength: 255
),
'city' => new Schema(
type: Type::STRING,
minLength: 1,
maxLength: 255
),
'zip' => new Schema(
type: Type::STRING,
pattern: '^[0-9]{5}$'
)
],
use O21\JsonSchema\Schema;
$schema = new Schema(
transform: function (stdClass $schema): void {
$schema->foo = 'bar';
}
);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.