1. Go to this page and download the library: Download giann/schematics 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/ */
giann / schematics example snippets
enum Sex: string
{
case Male = 'male';
case Female = 'female';
case Other = 'other';
}
#[ObjectSchema]
class Person
{
public function __construct(
#[StringSchema(format: Format::Uuid)]
#[Description('unique id of the person')]
public string $id,
#[ArraySchema(
items: new StringSchema(),
minContains: 1
)]
public array $names,
#[IntegerSchema(minimum: 0)]
public int $age,
#[StringSchema(enumClass: Sex::class)]
public string $sex,
// Inferred $ref to self
public ?Person $father = null
) {
}
}
enum Power: string
{
case Fly = 'weeeee!';
case Strong = 'smash!';
case Psychic = 'hummmm!';
}
// Infer $allOf Person
#[ObjectSchema]
class Hero extends Person
{
public function __construct(
string $id,
array $names,
int $age,
string $sex,
?Person $father = null,
// Infers string property
public string $superName,
#[StringSchema(enumClass: Power::class)]
public string $power
) {
parent::__construct($id, $names, $age, $sex, $father);
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.