{"id":21558308,"url":"https://github.com/021-projects/json-schema","last_synced_at":"2026-02-27T03:31:31.909Z","repository":{"id":264331550,"uuid":"893071427","full_name":"021-projects/json-schema","owner":"021-projects","description":"Object-Oriented JSON Schema Generation","archived":false,"fork":false,"pushed_at":"2024-11-23T13:47:35.000Z","size":13,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-07-21T09:33:00.966Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/021-projects.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-11-23T13:09:08.000Z","updated_at":"2025-06-23T18:17:26.000Z","dependencies_parsed_at":null,"dependency_job_id":"3dbf8d6d-da93-45b6-8543-15b5de58da5b","html_url":"https://github.com/021-projects/json-schema","commit_stats":null,"previous_names":["021-projects/json-schema"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/021-projects/json-schema","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/021-projects%2Fjson-schema","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/021-projects%2Fjson-schema/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/021-projects%2Fjson-schema/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/021-projects%2Fjson-schema/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/021-projects","download_url":"https://codeload.github.com/021-projects/json-schema/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/021-projects%2Fjson-schema/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29883694,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-26T23:51:21.483Z","status":"online","status_checked_at":"2026-02-27T02:00:06.759Z","response_time":57,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-24T08:14:32.467Z","updated_at":"2026-02-27T03:31:31.875Z","avatar_url":"https://github.com/021-projects.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Object-Oriented JSON Schema Generation in PHP\n\u003cp align=\"center\"\u003e\n\u003ca href=\"https://packagist.org/packages/021/json-schema\"\u003e\u003cimg src=\"https://img.shields.io/packagist/dt/021/json-schema\" alt=\"Total Downloads\"\u003e\u003c/a\u003e\n\u003ca href=\"https://packagist.org/packages/021/json-schema\"\u003e\u003cimg src=\"https://img.shields.io/packagist/v/021/json-schema\" alt=\"Latest Stable Version\"\u003e\u003c/a\u003e\n\u003ca href=\"https://packagist.org/packages/021/json-schema\"\u003e\u003cimg src=\"https://img.shields.io/packagist/l/021/json-schema\" alt=\"License\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\nThis library provides a way to generate JSON schemas in PHP using an object-oriented approach. It is inspired by the [JSON Schema](https://json-schema.org/) standard and aims to provide a way to generate JSON schemas in a more readable and maintainable way.\n\n## Installation\n```bash\ncomposer require 021/json-schema\n```\n\n## Usage\n```php\nuse O21\\JsonSchema\\Schema;\nuse O21\\JsonSchema\\Enums\\Type;\nuse O21\\JsonSchema\\Enums\\Format;\n\n$schema = new Schema(\n    schema: 'http://json-schema.org/draft-07/schema#',\n    type: Type::OBJECT,\n    properties: [\n        'name' =\u003e new Schema(\n            type: Type::STRING,\n            minLength: 1,\n            maxLength: 255\n        ),\n        'age' =\u003e new Schema(\n            type: Type::INTEGER,\n            minimum: 0,\n            maximum: 150\n        ),\n        'addresses' =\u003e new Schema(\n            type: Type::ARRAY,\n            items: new Schema(\n                type: Type::OBJECT,\n                properties: [\n                    'street' =\u003e new Schema(\n                        type: Type::STRING,\n                        minLength: 1,\n                        maxLength: 255\n                    ),\n                    'city' =\u003e new Schema(\n                        type: Type::STRING,\n                        minLength: 1,\n                        maxLength: 255\n                    ),\n                    'zip' =\u003e new Schema(\n                        type: Type::STRING,\n                        pattern: '^[0-9]{5}$'\n                    )\n                ],\n                required: ['street', 'city', 'zip']\n            ),\n        ),\n        'email' =\u003e new Schema(\n            type: Type::STRING,\n            format: Format::EMAIL\n        ),\n        'phone' =\u003e new Schema(\n            type: Type::STRING,\n            pattern: '^\\+[0-9]{1,3}\\.[0-9]{1,14}$'\n        ),\n        'is_active' =\u003e new Schema(\n            type: Type::BOOLEAN,\n            default: true,\n        ),\n    ]\n);\n// Convert the schema to JSON\n$json = $schema-\u003etoJson();\n// Convert the schema to an object\n$obj = $schema-\u003etoObject();\n```\n\n### Transform\nAlmost all properties listed on the [JSON Schema reference](https://json-schema.org/understanding-json-schema/reference) are supported, but if some properties are missing in the current version of the library or you want to add your own, you can use the transform method.\nIt is called when the `Schema` class is transformed into the `stdClass` class to generate JSON from it:\n```php\nuse O21\\JsonSchema\\Schema;\n\n$schema = new Schema(\n    transform: function (stdClass $schema): void {\n        $schema-\u003efoo = 'bar';\n    }\n);\n```\n\n## Support Us\n- **Bitcoin**: 1G4U12A7VVVaUrmj4KmNt4C5SaDmCXuW49\n- **Litecoin**: LXjysogo9AHiNE7AnUm4zjprDzCCWVESai\n- **Ethereum**: 0xd23B42D0A84aB51a264953f1a9c9A393c5Ffe4A1\n- **Tron**: TWEcfzu2UAPsbotZJh8DrEpvdZGho79jTg\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F021-projects%2Fjson-schema","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F021-projects%2Fjson-schema","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F021-projects%2Fjson-schema/lists"}