{"id":15026809,"url":"https://github.com/llm-agents-php/schema-mapper","last_synced_at":"2025-10-30T20:31:29.816Z","repository":{"id":255128897,"uuid":"848623585","full_name":"llm-agents-php/schema-mapper","owner":"llm-agents-php","description":"This package is a super handy JSON Schema Mapper for the LLM Agents project.","archived":false,"fork":false,"pushed_at":"2024-09-01T13:47:15.000Z","size":10,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-02T12:41:31.435Z","etag":null,"topics":["json-schema-generator","llm-agents","php","php8"],"latest_commit_sha":null,"homepage":"","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/llm-agents-php.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}},"created_at":"2024-08-28T05:22:43.000Z","updated_at":"2024-09-21T04:23:37.000Z","dependencies_parsed_at":"2024-08-28T06:46:21.119Z","dependency_job_id":"86f8a2e7-c33b-4460-9393-fbf97bd1c8db","html_url":"https://github.com/llm-agents-php/schema-mapper","commit_stats":null,"previous_names":["llm-agents-php/schema-mapper"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/llm-agents-php%2Fschema-mapper","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/llm-agents-php%2Fschema-mapper/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/llm-agents-php%2Fschema-mapper/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/llm-agents-php%2Fschema-mapper/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/llm-agents-php","download_url":"https://codeload.github.com/llm-agents-php/schema-mapper/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239053453,"owners_count":19574152,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["json-schema-generator","llm-agents","php","php8"],"created_at":"2024-09-24T20:05:10.646Z","updated_at":"2025-10-30T20:31:29.393Z","avatar_url":"https://github.com/llm-agents-php.png","language":"PHP","readme":"# JSON Schema Mapper for LLM Agents\n\n[![PHP](https://img.shields.io/packagist/php-v/llm-agents/json-schema-mapper.svg?style=flat-square)](https://packagist.org/packages/llm-agents/json-schema-mapper)\n[![Latest Version on Packagist](https://img.shields.io/packagist/v/llm-agents/json-schema-mapper.svg?style=flat-square)](https://packagist.org/packages/llm-agents/json-schema-mapper)\n[![Total Downloads](https://img.shields.io/packagist/dt/llm-agents/json-schema-mapper.svg?style=flat-square)](https://packagist.org/packages/llm-agents/json-schema-mapper)\n\nThis package is a super handy JSON Schema Mapper for the LLM Agents project.\n\n## What's it all about?\n\nThis package gives you a nifty SchemaMapper that can:\n\n- Convert PHP classes to JSON schemas\n- Turn JSON data into PHP objects\n\n## Class Diagram\n\nHere's a quick look at how the main components fit together:\n\n```mermaid\nclassDiagram\n    class SchemaMapperInterface {\n        \u003c\u003cinterface\u003e\u003e\n        +toJsonSchema(string $class): array\n        +toObject(string $json, ?string $class): object\n    }\n    class SchemaMapper {\n        -generator: JsonSchemaGenerator\n        -mapper: TreeMapper\n        +toJsonSchema(string $class): array\n        +toObject(string $json, ?string $class): object\n    }\n    SchemaMapperInterface \u003c|.. SchemaMapper\n    SchemaMapper --\u003e JsonSchemaGenerator\n    SchemaMapper --\u003e TreeMapper\n```\n\n## Getting Started\n\n### Installation\n\nFirst things first, let's get this package installed:\n\n```bash\ncomposer require llm-agents/json-schema-mapper\n```\n\n### Setting it up in Spiral\n\nIf you're using the Spiral framework (and why wouldn't you be? It's awesome!), you'll need to register the bootloader.\n\n**Here's how:**\n\n1. Open up your `app/src/Application/Kernel.php` file.\n2. Add the `LLM\\Agents\\JsonSchema\\Mapper\\Integration\\Spiral\\SchemaMapperBootloader` to the `defineBootloaders()` method:\n\n```php\nclass Kernel extends \\Spiral\\Framework\\Kernel\n{\n    // ...\n\n    public function defineBootloaders(): array\n    {\n        return [\n            // ... other bootloaders ...\n            \\LLM\\Agents\\JsonSchema\\Mapper\\Integration\\Spiral\\SchemaMapperBootloader::class,\n        ];\n    }\n}\n```\n\nAnd that's it! The bootloader will take care of registering all the necessary components for you.\n\n### Setting it up in Laravel\n\nIf you're using the Laravel framework, you'll need to register the Service provider.\n\n**Here's how:**\n\nJust register the `LLM\\Agents\\JsonSchema\\Mapper\\Integration\\Laravel\\SchemaMapperServiceProvider`\n\nAnd that's it! The service provider will take care of registering all the necessary components for you.\n\n## How to Use It\n\n### Converting a PHP Class to JSON Schema\n\nLet's say you have a `User` class and you want to get its JSON schema:\n\n```php\nuse LLM\\Agents\\JsonSchema\\Mapper\\SchemaMapperInterface;\n\nclass UserController\n{\n    public function __construct(\n        private SchemaMapperInterface $schemaMapper\n    ) {}\n\n    public function getUserSchema(): array\n    {\n        return $this-\u003eschemaMapper-\u003etoJsonSchema(User::class);\n    }\n}\n```\n\n### Converting JSON to a PHP Object\n\nGot some JSON data that you want to turn into a PHP object? No problem:\n\n```php\nuse LLM\\Agents\\JsonSchema\\Mapper\\SchemaMapperInterface;\n\nclass UserService\n{\n    public function __construct(\n        private SchemaMapperInterface $schemaMapper\n    ) {}\n\n    public function createUserFromJson(string $json): User\n    {\n        return $this-\u003eschemaMapper-\u003etoObject($json, User::class);\n    }\n}\n```\n\n## Contributing\n\nWe'd love your help to make this package even better! Here's how you can contribute:\n\n1. Fork the repository\n2. Write some awesome code\n3. Create a new Pull Request\n\nPlease make sure your code follows PSR-12 coding standards and include tests for any new features.\n\n## License\n\nThis package is open-sourced software licensed under the MIT license. Feel free to use it, modify it, and share it!\n\n---\n\nThat's all, folks! If you have any questions or run into any issues, don't hesitate to open an issue on GitHub.","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fllm-agents-php%2Fschema-mapper","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fllm-agents-php%2Fschema-mapper","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fllm-agents-php%2Fschema-mapper/lists"}