{"id":14966376,"url":"https://github.com/yiisoft/hydrator","last_synced_at":"2025-05-07T10:36:01.343Z","repository":{"id":157394637,"uuid":"633349575","full_name":"yiisoft/hydrator","owner":"yiisoft","description":"Create and populate objects with type casting, mapping and dependencies resolving support.","archived":false,"fork":false,"pushed_at":"2025-04-21T11:22:21.000Z","size":228,"stargazers_count":27,"open_issues_count":7,"forks_count":3,"subscribers_count":15,"default_branch":"master","last_synced_at":"2025-04-30T19:39:42.367Z","etag":null,"topics":["hydrator","yii3"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yiisoft.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":".github/CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE.md","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":".github/SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"open_collective":"yiisoft","github":["yiisoft"]}},"created_at":"2023-04-27T10:01:18.000Z","updated_at":"2025-04-21T11:22:25.000Z","dependencies_parsed_at":"2023-12-13T03:35:02.195Z","dependency_job_id":"654e2d27-a743-4273-836c-cec950b98d35","html_url":"https://github.com/yiisoft/hydrator","commit_stats":{"total_commits":75,"total_committers":8,"mean_commits":9.375,"dds":"0.29333333333333333","last_synced_commit":"69ab3fe29568cc971fc486cb449d67657eba4e5b"},"previous_names":[],"tags_count":7,"template":false,"template_full_name":"yiisoft/package-template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yiisoft%2Fhydrator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yiisoft%2Fhydrator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yiisoft%2Fhydrator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yiisoft%2Fhydrator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yiisoft","download_url":"https://codeload.github.com/yiisoft/hydrator/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252443773,"owners_count":21748720,"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":["hydrator","yii3"],"created_at":"2024-09-24T13:36:17.674Z","updated_at":"2025-05-07T10:36:01.313Z","avatar_url":"https://github.com/yiisoft.png","language":"PHP","funding_links":["https://opencollective.com/yiisoft","https://github.com/sponsors/yiisoft"],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n    \u003ca href=\"https://github.com/yiisoft\" target=\"_blank\"\u003e\n        \u003cimg src=\"https://yiisoft.github.io/docs/images/yii_logo.svg\" height=\"100px\" alt=\"Yii\"\u003e\n    \u003c/a\u003e\n    \u003ch1 align=\"center\"\u003eYii Hydrator\u003c/h1\u003e\n    \u003cbr\u003e\n\u003c/p\u003e\n\n[![Latest Stable Version](https://poser.pugx.org/yiisoft/hydrator/v)](https://packagist.org/packages/yiisoft/hydrator)\n[![Total Downloads](https://poser.pugx.org/yiisoft/hydrator/downloads)](https://packagist.org/packages/yiisoft/hydrator)\n[![Build status](https://github.com/yiisoft/hydrator/actions/workflows/build.yml/badge.svg)](https://github.com/yiisoft/hydrator/actions/workflows/build.yml)\n[![Code Coverage](https://codecov.io/gh/yiisoft/hydrator/branch/master/graph/badge.svg)](https://codecov.io/gh/yiisoft/hydrator)\n[![Mutation testing badge](https://img.shields.io/endpoint?style=flat\u0026url=https%3A%2F%2Fbadge-api.stryker-mutator.io%2Fgithub.com%2Fyiisoft%2Fhydrator%2Fmaster)](https://dashboard.stryker-mutator.io/reports/github.com/yiisoft/hydrator/master)\n[![static analysis](https://github.com/yiisoft/hydrator/workflows/static%20analysis/badge.svg)](https://github.com/yiisoft/hydrator/actions?query=workflow%3A%22static+analysis%22)\n[![type-coverage](https://shepherd.dev/github/yiisoft/hydrator/coverage.svg)](https://shepherd.dev/github/yiisoft/hydrator)\n[![psalm-level](https://shepherd.dev/github/yiisoft/hydrator/level.svg)](https://shepherd.dev/github/yiisoft/hydrator)\n\nThe package provides a way to create and hydrate objects from a set of raw data.\n\nFeatures are:\n\n- supports properties of any visibility;\n- uses constructor arguments to create objects;\n- resolves dependencies when creating objects using [PSR-11](https://www.php-fig.org/psr/psr-11/) compatible DI container\n  provided;\n- supports nested objects;\n- supports mapping;\n- allows fine-tuning hydration via PHP attributes.\n\n## Requirements\n\n- PHP 8.1 or higher.\n\n## Installation\n\nThe package could be installed with [Composer](https://getcomposer.org):\n\n```shell\ncomposer require yiisoft/hydrator\n```\n\n## General usage\n\nTo hydrate existing object:\n\n```php\nuse Yiisoft\\Hydrator\\Hydrator;\n\n$hydrator = new Hydrator();\n$hydrator-\u003ehydrate($object, $data);\n```\n\nTo create a new object and fill it with the data:\n\n```php\nuse Yiisoft\\Hydrator\\Hydrator;\n\n$hydrator = new Hydrator();\n$object = $hydrator-\u003ecreate(MyClass::class, $data);\n```\n\nTo pass arguments to the constructor of a nested object, use nested array or dot-notation:\n\n```php\nfinal class Engine\n{\n    public function __construct(\n        private string $name,\n    ) {}\n}\n\nfinal class Car\n{\n    public function __construct(\n        private string $name,\n        private Engine $engine,\n    ) {}\n}\n\n// nested array\n$object = $hydrator-\u003ecreate(Car::class, [\n    'name' =\u003e 'Ferrari',\n    'engine' =\u003e [\n        'name' =\u003e 'V8',\n    ]\n]);\n\n// or dot-notation\n$object = $hydrator-\u003ecreate(Car::class, [\n    'name' =\u003e 'Ferrari',\n    'engine.name' =\u003e 'V8',\n]);\n```\n\nThat would pass the `name` constructor argument of the `Car` object and create a new `Engine` object for `engine`\nargument passing `V8` as the `name` argument to its constructor.\n\n## Documentation\n\n- Guide: [English](docs/guide/en/README.md), [Português - Brasil](docs/guide/pt-BR/README.md), [Русский](docs/guide/ru/README.md)\n- [Internals](docs/internals.md)\n\nIf you need help or have a question, the [Yii Forum](https://forum.yiiframework.com/c/yii-3-0/63) is a good place for that.\nYou may also check out other [Yii Community Resources](https://www.yiiframework.com/community).\n\n## License\n\nThe Yii Hydrator is free software. It is released under the terms of the BSD License.\nPlease see [`LICENSE`](./LICENSE.md) for more information.\n\nMaintained by [Yii Software](https://www.yiiframework.com/).\n\n## Support the project\n\n[![Open Collective](https://img.shields.io/badge/Open%20Collective-sponsor-7eadf1?logo=open%20collective\u0026logoColor=7eadf1\u0026labelColor=555555)](https://opencollective.com/yiisoft)\n\n## Follow updates\n\n[![Official website](https://img.shields.io/badge/Powered_by-Yii_Framework-green.svg?style=flat)](https://www.yiiframework.com/)\n[![Twitter](https://img.shields.io/badge/twitter-follow-1DA1F2?logo=twitter\u0026logoColor=1DA1F2\u0026labelColor=555555?style=flat)](https://twitter.com/yiiframework)\n[![Telegram](https://img.shields.io/badge/telegram-join-1DA1F2?style=flat\u0026logo=telegram)](https://t.me/yii3en)\n[![Facebook](https://img.shields.io/badge/facebook-join-1DA1F2?style=flat\u0026logo=facebook\u0026logoColor=ffffff)](https://www.facebook.com/groups/yiitalk)\n[![Slack](https://img.shields.io/badge/slack-join-1DA1F2?style=flat\u0026logo=slack)](https://yiiframework.com/go/slack)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyiisoft%2Fhydrator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyiisoft%2Fhydrator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyiisoft%2Fhydrator/lists"}