{"id":15028011,"url":"https://github.com/zarganwar/php-di-nextras-orm-extension","last_synced_at":"2026-02-06T08:37:59.202Z","repository":{"id":215492448,"uuid":"739061092","full_name":"Zarganwar/php-di-nextras-orm-extension","owner":"Zarganwar","description":"Nextras ORM extension for php-di","archived":false,"fork":false,"pushed_at":"2024-01-04T17:49:48.000Z","size":5,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-08T23:47:54.180Z","etag":null,"topics":["nextras-orm","php-81","php-di","php-di-container"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Zarganwar.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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-01-04T17:20:23.000Z","updated_at":"2024-03-08T19:29:42.000Z","dependencies_parsed_at":null,"dependency_job_id":"0a8bb906-4123-48bb-ae33-cb8d9cb83402","html_url":"https://github.com/Zarganwar/php-di-nextras-orm-extension","commit_stats":null,"previous_names":["zarganwar/php-di-nextras-orm-extension"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Zarganwar%2Fphp-di-nextras-orm-extension","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Zarganwar%2Fphp-di-nextras-orm-extension/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Zarganwar%2Fphp-di-nextras-orm-extension/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Zarganwar%2Fphp-di-nextras-orm-extension/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Zarganwar","download_url":"https://codeload.github.com/Zarganwar/php-di-nextras-orm-extension/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243338260,"owners_count":20275460,"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":["nextras-orm","php-81","php-di","php-di-container"],"created_at":"2024-09-24T20:07:28.351Z","updated_at":"2026-02-06T08:37:59.157Z","avatar_url":"https://github.com/Zarganwar.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"## How to use\n\n\n## Create your model classes see [Nextras/Orm](https://nextras.org/orm)\n\n### Entities\n\n```php\nuse Nextras\\Orm\\Entity\\Entity;\n\n/**\n * @property-read int $id {primary}\n * @property string $name\n */\nfinal class Account extends Entity\n{\n\n}\n```\n\n\n### Mappers\n\n```php\nuse \\Nextras\\Orm\\Mapper\\Mapper;\n\nfinal class AccountMapper extends Mapper\n{\n\n}\n```\n\n\n### Repositories\n\nUse `RepositoryMapper` attribute to map repository to mapper class \n\n```php\n\nuse Zarganwar\\PhpDiNextrasOrmExtension\\NextrasOrmPhpDiExtension\\Attributes\\RepositoryMapper;\nuse Nextras\\Orm\\Repository\\Repository;\n\n#[RepositoryMapper(AccountMapper::class)]\nfinal class AccountRepository extends Repository\n{\n\n\tpublic static function getEntityClassNames(): array\n\t{\n\t\treturn [Account::class];\n\t}\n\n}\n\n```\n\n\n### Model\n- Use `ModelRepository` attribute to map repository to model class.\n- Every repository must be mapped to model class!\n- !Do not configure model by [Nextras/Orm - Nette](https://nextras.org/orm/docs/main/config-nette)!\n\n```php\n\nuse Zarganwar\\PhpDiNextrasOrmExtension\\NextrasOrmPhpDiExtension\\Attributes\\ModelRepository;\n\n#[ModelRepository(AccountRepository::class, 'accounts')]\n// ...\n// ...\nfinal class Model extends \\Nextras\\Orm\\Model\\Model\n{\n\n}\n```\n\n\n## Register extension\n\nUse Config class to configure extension\n\n```php\n// config.php\nuse Zarganwar\\PhpDiNextrasOrmExtension\\NextrasOrmPhpDiExtension\\Config;\nuse Zarganwar\\PhpDiNextrasOrmExtension\\NextrasOrmPhpDiExtension\\OrmExtension;\nuse Psr\\Container\\ContainerInterface;\n\nreturn [\n    // Configure extension\n\tConfig::class =\u003e fn(ContainerInterface $c) =\u003e new Config(\n\t\tcacheDirectory: __DIR__ . '/../var/cache',\n\t\tmodelClass: Model::class,\n\t\tconnection: [/* See class PhpDoc */]\n\t),\n\n    // Register extension\n\tOrmExtension::class =\u003e fn(ContainerInterface $container) =\u003e new OrmExtension(\n\t\t$container, \n\t\t$container-\u003eget(Config::class),\n\t),\n];\n```\n\nAfter container build call `OrmExtension::register` method\n\n```php\n$containerBuilder = new DI\\ContainerBuilder();\n$containerBuilder-\u003eaddDefinitions(__DIR__ . '/config.php');\n$build = $containerBuilder-\u003ebuild();\n\n$build-\u003ecall([OrmExtension::class, 'register']);\n```\n\n## Enjoy\n\n```php\n$container-\u003eget(AccountRepository::class)-\u003efindAll(); // Returns Nextras\\Orm\\Collection\\ICollection\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzarganwar%2Fphp-di-nextras-orm-extension","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzarganwar%2Fphp-di-nextras-orm-extension","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzarganwar%2Fphp-di-nextras-orm-extension/lists"}