{"id":33997419,"url":"https://github.com/ray-di/ray.doctrineormmodule","last_synced_at":"2026-06-08T14:30:56.487Z","repository":{"id":57046782,"uuid":"49503204","full_name":"ray-di/Ray.DoctrineOrmModule","owner":"ray-di","description":"A Doctrine ORM Module for Ray.Di","archived":false,"fork":false,"pushed_at":"2016-08-31T23:30:52.000Z","size":43,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"1.x","last_synced_at":"2025-07-20T12:46:52.370Z","etag":null,"topics":["doctrine-orm","ray-module"],"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/ray-di.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}},"created_at":"2016-01-12T13:55:12.000Z","updated_at":"2017-02-19T13:20:51.000Z","dependencies_parsed_at":"2022-08-24T05:00:23.864Z","dependency_job_id":null,"html_url":"https://github.com/ray-di/Ray.DoctrineOrmModule","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/ray-di/Ray.DoctrineOrmModule","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ray-di%2FRay.DoctrineOrmModule","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ray-di%2FRay.DoctrineOrmModule/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ray-di%2FRay.DoctrineOrmModule/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ray-di%2FRay.DoctrineOrmModule/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ray-di","download_url":"https://codeload.github.com/ray-di/Ray.DoctrineOrmModule/tar.gz/refs/heads/1.x","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ray-di%2FRay.DoctrineOrmModule/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":27702869,"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-12-13T02:00:09.769Z","response_time":147,"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":["doctrine-orm","ray-module"],"created_at":"2025-12-13T08:57:52.437Z","updated_at":"2025-12-13T08:57:53.537Z","avatar_url":"https://github.com/ray-di.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Ray.DoctrineOrmModule\n\n[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/kawanamiyuu/Ray.DoctrineOrmModule/badges/quality-score.png?b=1.x)](https://scrutinizer-ci.com/g/kawanamiyuu/Ray.DoctrineOrmModule/?branch=1.x)\n[![Code Coverage](https://scrutinizer-ci.com/g/kawanamiyuu/Ray.DoctrineOrmModule/badges/coverage.png?b=1.x)](https://scrutinizer-ci.com/g/kawanamiyuu/Ray.DoctrineOrmModule/?branch=1.x)\n[![Build Status](https://travis-ci.org/kawanamiyuu/Ray.DoctrineOrmModule.svg?branch=1.x)](https://travis-ci.org/kawanamiyuu/Ray.DoctrineOrmModule)\n[![Packagist](https://img.shields.io/packagist/v/ray/doctrine-orm-module.svg?maxAge=3600)](https://packagist.org/packages/ray/doctrine-orm-module)\n[![Packagist](https://img.shields.io/packagist/l/ray/doctrine-orm-module.svg?maxAge=3600)](https://github.com/kawanamiyuu/Ray.DoctrineOrmModule/blob/1.x/LICENSE)\n\nA [Doctrine ORM](https://github.com/doctrine/doctrine2) Module for [Ray.Di](https://github.com/ray-di/Ray.Di)\n\n## Installation\n\n### Composer install\n\n```bash\n$ composer require ray/doctrine-orm-module\n```\n\n### Module install\n\n```php\nuse Ray\\Di\\AbstractModule;\nuse Ray\\DoctrineOrmModule\\EntityManagerModule;\n\nclass AppModule extends AbstractModule\n{\n    protected function configure()\n    {\n        $entityDir = '/path/to/Entity/';\n\n        $params = [\n            'driver'   =\u003e 'pdo_pgsql',\n            'user'     =\u003e 'username',\n            'password' =\u003e 'password',\n            'host'     =\u003e '127.0.0.1'\n            'port'     =\u003e '5432',\n            'dbname'   =\u003e 'myapp_db'\n        ];\n\n        $this-\u003einstall(new EntityManagerModule($params, $entityDir));\n\n        //// OR ////\n\n        $params = [\n            'url' =\u003e 'postgresql://username:password@127.0.0.1:5432/myapp_db'\n        ];\n\n        $this-\u003einstall(new EntityManagerModule($params, $entityDir));\n    }\n}\n```\n\nLearn more about [the database connection configuration](http://docs.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html).\n\n## DI trait\n\n * [EntityManagerInject](https://github.com/kawanamiyuu/Ray.DoctrineOrmModule/blob/1.x/src/EntityManagerInject.php) for `Doctrine\\ORM\\EntityManagerInterface` interface\n\n## Transaction management\n\nFirst, install `TransactionalModule`.\n\n```php\nuse Ray\\Di\\AbstractModule;\nuse Ray\\DoctrineOrmModule\\EntityManagerModule;\nuse Ray\\DoctrineOrmModule\\TransactionalModule;\n\nclass AppModule extends AbstractModule\n{\n    protected function configure()\n    {\n        $this-\u003einstall(new EntityManagerModule($params, $entityDir));\n\n        $this-\u003einstall(new TransactionalModule); // \u003c--\n    }\n}\n```\n\nAny method in the class marked with `@Transactional` is executed in a transaction.\n\n```php\nuse Ray\\DoctrineOrmModule\\Annotation\\Transactional;\nuse Ray\\DoctrineOrmModule\\EntityManagerInject;\n\n/**\n * @Transactional\n */\nclass UserService\n{\n    use EntityManagerInject;\n\n    public function foo()\n    {\n        // transaction is active\n        $this-\u003eentityManager-\u003e...;\n    }\n\n    public function bar()\n    {\n        // transaction is active\n        $this-\u003eentityManager-\u003e...;\n    }\n}\n```\n\nThe method marked with `@Transactional` is executed in a transaction.\n\n```php\nuse Ray\\DoctrineOrmModule\\Annotation\\Transactional;\nuse Ray\\DoctrineOrmModule\\EntityManagerInject;\n\nclass UserService\n{\n    use EntityManagerInject;\n\n    /**\n     * @Transactional\n     */\n    public function foo()\n    {\n        // transaction is active\n        $this-\u003eentityManager-\u003e...;\n    }\n\n    public function bar()\n    {\n        // transaction is not active\n        $this-\u003eentityManager-\u003e...;\n    }\n}\n```\n\n## Generating Proxy classes (for production)\n\nProxy classes improve the performance in a production environment.\nIf you bind `ProxyDir`, proxy classes are automatically generated into the directory when they are used the first time.\n\n```php\nuse Ray\\Di\\AbstractModule;\nuse Ray\\DoctrineOrmModule\\Annotation\\ProxyDir;\nuse Ray\\DoctrineOrmModule\\EntityManagerModule;\n\nclass AppModule extends AbstractModule\n{\n    protected function configure()\n    {\n        $this-\u003ebind()-\u003eannotatedWith(ProxyDir::class)-\u003etoInstance('/path/to/proxy'); // \u003c--\n\n        $this-\u003einstall(new EntityManagerModule($params, $entityDir));\n    }\n}\n```\n\nLearn more about [the Proxy Object](http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/advanced-configuration.html#proxy-objects).\n\n## Logging queries\n\nIf you want to log queries, you additionally need to bind `Psr\\Log\\LoggerInterface` and install `SqlLoggerModule`.\n\n```php\nuse Monolog\\Logger;\nuse Psr\\Log\\LoggerInterface;\nuse Ray\\Di\\AbstractModule;\nuse Ray\\DoctrineOrmModule\\EntityManagerModule;\nuse Ray\\DoctrineOrmModule\\SqlLoggerModule;\nuse Ray\\DoctrineOrmModule\\TransactionalModule;\n\nclass AppModule extends AbstractModule\n{\n    protected function configure()\n    {\n        $this-\u003einstall(new EntityManagerModule($params, $entityDir));\n        $this-\u003einstall(new TransactionalModule);\n\n        $this-\u003ebind(LoggerInterface::class)-\u003etoInstance(new Logger('myapp')); // \u003c--\n        $this-\u003einstall(new SqlLoggerModule); // \u003c--\n    }\n}\n```\n\n## Demo\n\n```bash\n$ php docs/demo/run.php\n// It works!\n```\n\n## Requirements\n\n * PHP 5.6+\n * hhvm\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fray-di%2Fray.doctrineormmodule","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fray-di%2Fray.doctrineormmodule","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fray-di%2Fray.doctrineormmodule/lists"}