{"id":18376427,"url":"https://github.com/cycle/orm-promise-mapper","last_synced_at":"2025-09-09T18:35:37.754Z","repository":{"id":45078885,"uuid":"438661437","full_name":"cycle/orm-promise-mapper","owner":"cycle","description":"Promise mapper","archived":false,"fork":false,"pushed_at":"2025-05-02T11:29:00.000Z","size":80,"stargazers_count":3,"open_issues_count":0,"forks_count":4,"subscribers_count":3,"default_branch":"1.x","last_synced_at":"2025-08-27T20:42:49.201Z","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/cycle.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","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":"2021-12-15T14:35:56.000Z","updated_at":"2025-07-04T09:45:27.000Z","dependencies_parsed_at":"2025-04-06T20:42:22.098Z","dependency_job_id":null,"html_url":"https://github.com/cycle/orm-promise-mapper","commit_stats":{"total_commits":7,"total_committers":3,"mean_commits":"2.3333333333333335","dds":0.4285714285714286,"last_synced_commit":"430731414ba649d37918012ffc3094f7bbacd1a5"},"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/cycle/orm-promise-mapper","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cycle%2Form-promise-mapper","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cycle%2Form-promise-mapper/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cycle%2Form-promise-mapper/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cycle%2Form-promise-mapper/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cycle","download_url":"https://codeload.github.com/cycle/orm-promise-mapper/tar.gz/refs/heads/1.x","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cycle%2Form-promise-mapper/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274340921,"owners_count":25267297,"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","status":"online","status_checked_at":"2025-09-09T02:00:10.223Z","response_time":80,"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-06T00:23:18.112Z","updated_at":"2025-09-09T18:35:37.726Z","avatar_url":"https://github.com/cycle.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Cycle ORM PromiseMapper\n[![Latest Stable Version](https://poser.pugx.org/cycle/orm-promise-mapper/version)](https://packagist.org/packages/cycle/orm-promise-mapper)\n[![Build Status](https://github.com/cycle/orm-promise-mapper/workflows/build/badge.svg)](https://github.com/cycle/orm-promise-mapper/actions)\n[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/cycle/orm-promise-mapper/badges/quality-score.png?b=1.x)](https://scrutinizer-ci.com/g/cycle/orm-promise-mapper/?branch=1.x)\n[![Codecov](https://codecov.io/gh/cycle/orm-promise-mapper/graph/badge.svg)](https://codecov.io/gh/cycle/orm-promise-mapper)\n\u003ca href=\"https://discord.gg/TFeEmCs\"\u003e\u003cimg src=\"https://img.shields.io/badge/discord-chat-magenta.svg\"\u003e\u003c/a\u003e\n\nCycle ORM provides the ability to carry data over the specific class instances by using `cycle/orm-promise-mapper`\npackage with `\\Cycle\\ORM\\Reference\\Promise` objects for relations with lazy loading.\n\n## Installation\n\nThe preferred way to install this package is through [Composer](https://getcomposer.org/download/):\n\n```bash\ncomposer require cycle/orm-promise-mapper\n```\n\n## Define the Entity\n\n```php\nuse Cycle\\Annotated\\Annotation\\Entity;\nuse Cycle\\Annotated\\Annotation\\Column;\nuse Cycle\\Annotated\\Annotation\\Relation\\BelongsTo;\nuse Cycle\\Annotated\\Annotation\\Relation\\HasMany;\nuse Cycle\\ORM\\Reference\\ReferenceInterface;\n\n#[Entity]\nclass User\n{\n    #[Column(type: 'primary')]\n    public int $id;\n\n    #[HasMany(target: Post::class, load: 'eager')]\n    public array $posts;\n    \n    #[HasMany(target: Tag::class, load: 'lazy')]\n    public ReferenceInterface|array $tags;\n}\n\n#[Entity]\nclass Post\n{\n    // ...\n\n    #[BelongsTo(target: User::class, load: 'lazy')]\n    public ReferenceInterface|User $user;\n\n    #[BelongsTo(target: Tag::class, load: 'eager')]\n    public Tag $tag;\n}\n```\n\n## Fetching entity data\n\n```php\n$user = $orm-\u003egetRepository('user')-\u003efindByPK(1);\n\n// $user-\u003eposts contains an array because of eager loading\nforeach ($user-\u003eposts as $post) {\n    // ...\n}\n\n// $user-\u003etags contains Cycle\\ORM\\Reference\\Promise object because of lazy loading\n$tags = $user-\u003etags-\u003efetch();\nforeach ($tags as $post) {\n    // ...\n}\n\n$post = $orm-\u003egetRepository('post')-\u003efindByPK(1);\n\n// $post-\u003euser contains Cycle\\ORM\\Reference\\Promise object because of lazy loading\n$userId = $post-\u003euser-\u003efetch()-\u003eid;\n\n// $post-\u003etag contains Tag object because of eager loading\n$tagName = $post-\u003etag-\u003ename;\n```\n\n## License:\n\nThe MIT License (MIT). Please see [`LICENSE`](./LICENSE) for more information.\nMaintained by [Spiral Scout](https://spiralscout.com).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcycle%2Form-promise-mapper","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcycle%2Form-promise-mapper","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcycle%2Form-promise-mapper/lists"}