{"id":20704905,"url":"https://github.com/streamcommon/doctrine-manager","last_synced_at":"2025-04-23T01:33:54.760Z","repository":{"id":37549245,"uuid":"169995581","full_name":"streamcommon/doctrine-manager","owner":"streamcommon","description":"PSR-11 Doctrine container manager","archived":false,"fork":false,"pushed_at":"2023-04-19T18:28:19.000Z","size":285,"stargazers_count":1,"open_issues_count":2,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-07-30T20:05:16.639Z","etag":null,"topics":["doctrine","php-component","php7","psr-11"],"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/streamcommon.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":"2019-02-10T15:55:47.000Z","updated_at":"2023-03-27T17:58:13.000Z","dependencies_parsed_at":"2022-08-24T14:25:31.107Z","dependency_job_id":null,"html_url":"https://github.com/streamcommon/doctrine-manager","commit_stats":null,"previous_names":[],"tags_count":20,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/streamcommon%2Fdoctrine-manager","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/streamcommon%2Fdoctrine-manager/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/streamcommon%2Fdoctrine-manager/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/streamcommon%2Fdoctrine-manager/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/streamcommon","download_url":"https://codeload.github.com/streamcommon/doctrine-manager/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224986224,"owners_count":17402938,"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":["doctrine","php-component","php7","psr-11"],"created_at":"2024-11-17T01:15:06.622Z","updated_at":"2024-11-17T01:15:07.325Z","avatar_url":"https://github.com/streamcommon.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# doctrine-manager\n[![Latest Stable Version](https://poser.pugx.org/streamcommon/doctrine-manager/v/stable)](https://packagist.org/packages/streamcommon/doctrine-manager)\n[![Total Downloads](https://poser.pugx.org/streamcommon/doctrine-manager/downloads)](https://packagist.org/packages/streamcommon/doctrine-manager)\n[![License](https://poser.pugx.org/streamcommon/doctrine-manager/license)](./LICENSE)\n\nThis package provide [Doctrine 2](https://github.com/doctrine) factories for [PRS-11](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-11-container.md) container standard.\n\n# Branches\n[![Master][Master branch image]][Master branch] [![Build Status][Master image]][Master] [![Coverage Status][Master coverage image]][Master coverage]\n\n[![Develop][Develop branch image]][Develop branch] [![Build Status][Develop image]][Develop] [![Coverage Status][Develop coverage image]][Develop coverage]\n\n## Installation\nConsole run:\n```console\n    composer require streamcommon/doctrine-manager\n```\nOr add into your `composer.json`:\n```json\n    \"require\": {\n        \"streamcommon/doctrine-manager\": \"*\"\n    }\n```\n\n## Please check doctrine documentation for more info\n* [ORM version 2.6](https://www.doctrine-project.org/projects/doctrine-orm/en/2.6/index.html)\n* [DBAL version 2.9](https://www.doctrine-project.org/projects/doctrine-dbal/en/2.9/index.html)\n* [Migrations version 2.1](https://www.doctrine-project.org/projects/doctrine-migrations/en/2.1/index.html) \n* [Event Manager version 1.0](https://www.doctrine-project.org/projects/doctrine-event-manager/en/latest/index.html)\n* [Metadata driver](https://www.doctrine-project.org/projects/doctrine-orm/en/2.6/reference/metadata-drivers.html#metadata-drivers)\n* [ORM Events](https://www.doctrine-project.org/projects/doctrine-orm/en/2.6/reference/events.html)\n* [Doctrine Annotation \u003e1.6](https://www.doctrine-project.org/projects/doctrine-annotations/en/1.6/index.html)\n* [Caching](https://www.doctrine-project.org/projects/doctrine-orm/en/2.6/reference/caching.html)\n* [Entity Manager](https://www.doctrine-project.org/projects/doctrine-orm/en/2.6/reference/working-with-objects.html)\n* [ZendFramework/zend-servicemanager](https://github.com/zendframework/zend-servicemanager)\n* [ZendFramework/zend-auradi-config](https://github.com/zendframework/zend-auradi-config)\n* [ZendFramework/zend-pimple-config](https://github.com/zendframework/zend-pimple-config)\n* [Jsoumelidis/zend-sf-di-config](https://github.com/jsoumelidis/zend-sf-di-config)\n* [Laminas/laminas-servicemanager](https://github.com/laminas/laminas-servicemanager)\n* [Laminas/laminas-auradi-config](https://github.com/laminas/laminas-auradi-config)\n* [Laminas/laminas-pimple-config](https://github.com/laminas/laminas-pimple-config)\n\n\n## Example configure project file\n\u003e `Psr\\Container\\ContainerInterface` container MUST have `config` key\n\nConfigure your project config file: \n\n1. Configure doctrine configuration like: \n    ```php\n    'config' =\u003e [\n        'doctrine' =\u003e [\n            'configuration' =\u003e [\n            // If you use single connection\n                'orm_default' =\u003e [\n                    'result_cache' =\u003e 'array',\n                    'metadata_cache' =\u003e 'array',\n                    'query_cache' =\u003e 'array',\n                    'hydration_cache' =\u003e 'array',\n                    'driver' =\u003e 'orm_default',\n                ],\n             \n            // If you want to add a second connection\n                'orm_custom' =\u003e [\n                    'result_cache' =\u003e 'memcached',\n                    'metadata_cache' =\u003e 'memcached',\n                    'query_cache' =\u003e 'memcached',\n                    'hydration_cache' =\u003e 'memcached',\n                    'driver' =\u003e 'orm_custom',\n                ],\n            ],\n    ```\n2. Configure connection options like: \n    ```php\n            'connection' =\u003e [\n            // If you use single connection\n            // Default using MySql connection\n                'orm_default' =\u003e [\n                    'configuration' =\u003e 'orm_default',\n                    'event_manager' =\u003e 'orm_default',\n                    'params' =\u003e [\n                        'dbname' =\u003e 'name',\n                        'user' =\u003e 'user',\n                        'password' =\u003e 'password',\n                        'host' =\u003e 'localhost',\n                    ],\n                ],\n             \n            // If you want to add a second connection\n            // Alternative Postgress connection\n                'orm_custom' =\u003e [\n                    'configuration' =\u003e 'orm_custom',\n                    'event_manager' =\u003e 'orm_custom',\n                    'driver_class_name' =\u003e \\Doctrine\\DBAL\\Driver\\PDOPgSql\\Driver::class,\n                    'params' =\u003e [\n                        'dbname' =\u003e 'name',\n                        'user' =\u003e 'user',\n                        'password' =\u003e 'password',\n                        'host' =\u003e 'localhost_custom',\n                    ],\n                ]\n            ],\n    ```\n3. Configure entity|event manager:\n    ```php\n            'entity_manager' =\u003e [\n                'orm_default' =\u003e [\n                    'connection' =\u003e 'orm_default',\n                    'configuration' =\u003e 'orm_default',\n                ],\n                'orm_custom' =\u003e [\n                    'connection' =\u003e 'orm_custom',\n                    'configuration' =\u003e 'orm_custom',\n                ]\n            ],\n            'event_manager' =\u003e [\n                'orm_default' =\u003e [\n                    'subscribers' =\u003e [],\n                ],\n                'orm_custom' =\u003e [\n                    'subscribers' =\u003e [],\n                ]\n            ],\n            'entity_resolver' =\u003e [\n                'orm_default' =\u003e [\n                    'resolvers' =\u003e [],\n                ],\n                'orm_custom' =\u003e [\n                    'resolvers' =\u003e [],\n                ],\n            ],\n    ```\n4. Configure orm driver, for example:\n    ```php\n            'driver' =\u003e [\n             // If you use single connection\n             // Annotation driver example \n             //@see https://www.doctrine-project.org/projects/doctrine-annotations/en/1.6/index.html\n                'orm_default' =\u003e [\n                    'class_name' =\u003e \\Doctrine\\Common\\Persistence\\Mapping\\Driver\\MappingDriverChain::class,\n                    'drivers' =\u003e [\n                       'Annotation\\Entity' =\u003e 'Annotation\\Entity' \n                    ],\n                ],\n                'Annotation\\Entity' =\u003e [\n                    'class_name' =\u003e \\Doctrine\\ORM\\Mapping\\Driver\\AnnotationDriver::class,\n                    'paths' =\u003e [\n                        __DIR__ . '/Annotation/Entity'\n                    ]\n                ],      \n          \n            // If you want to add a second connection\n            // Php driver for example\n                'orm_custom' =\u003e [\n                    'class_name' =\u003e \\Doctrine\\Common\\Persistence\\Mapping\\Driver\\MappingDriverChain::class,\n                    'drivers' =\u003e [\n                        'PHPDriver\\Entity' =\u003e 'PHPDriver\\Entity'\n                    ],\n                ],\n                'PHPDriver\\Entity' =\u003e [\n                    'class_name' =\u003e \\Doctrine\\Common\\Persistence\\Mapping\\Driver\\PHPDriver::class,\n                    'paths' =\u003e [\n                        __DIR__ . '/PHPDriver/Entity'\n                    ]\n                ], \n            ],\n    ```\n5. Configure doctrine cache:\n    ```php\n    //@see https://www.doctrine-project.org/projects/doctrine-orm/en/2.6/reference/caching.html\n            'cache' =\u003e [\n                'array' =\u003e [\n                    'class_name' =\u003e Doctrine\\Common\\Cache\\ArrayCache::class,\n                    'namespace' =\u003e 'Streamcommon\\Doctrine\\Manager\\Interop',\n                ]\n            ],\n        ]\n    ],\n    ```\n6. Configure your project dependencies:\n    ```php\n    use Streamcommon\\Doctrine\\Manager\\Common\\Factory\\{\n        Cache as CacheFactory,\n        Driver as DriverFactory,\n        EventManager as EventManagerFactory\n    };\n    use Streamcommon\\Doctrine\\Manager\\DBAL\\Factory\\Connection as ConnectionFactory;\n    use Streamcommon\\Doctrine\\Manager\\ORM\\Factory\\{\n        Configuration as ConfigurationFactory,\n        EntityManager as EntityManagerFactory,\n        EntityResolver as EntityResolverFactory,\n    };\n    \n    'dependencies' =\u003e [\n       'factories' =\u003e [\n       // If you use single connection\n            'doctrine.driver.orm_default'          =\u003e [DriverFactory::class, 'orm_default'],\n            'doctrine.event_manager.orm_default'   =\u003e [EventManagerFactory::class, 'orm_default'],\n            'doctrine.configuration.orm_default'   =\u003e [ConfigurationFactory::class, 'orm_default'],\n            'doctrine.connection.orm_default'      =\u003e [ConnectionFactory::class, 'orm_default'],\n            'doctrine.entity_resolver.orm_default' =\u003e [EntityResolverFactory::class, 'orm_default'],\n            'doctrine.entity_manager.orm_default'  =\u003e [EntityManagerFactory::class, 'orm_default'],\n            'doctrine.cache.array'                 =\u003e [CacheFactory::class, 'orm_default'],\n        \n       // If you want to add a second connection\n            'doctrine.driver.orm_custom'          =\u003e [DriverFactory::class, 'orm_custom'],\n            'doctrine.event_manager.orm_custom'   =\u003e [EventManagerFactory::class, 'orm_custom'],\n            'doctrine.configuration.orm_custom'   =\u003e [ConfigurationFactory::class, 'orm_custom'],\n            'doctrine.connection.orm_custom'      =\u003e [ConnectionFactory::class, 'orm_custom'],\n            'doctrine.entity_resolver.orm_custom' =\u003e [EntityResolverFactory::class, 'orm_custom'],\n            'doctrine.entity_manager.orm_custom'  =\u003e [EntityManagerFactory::class, 'orm_custom'],\n        ],\n    ]\n    ```\n7. Use in your project:\n    ```php\n    $em = $container-\u003eget('doctrine.entity_manager.orm_default');\n    $connection = $container-\u003eget('doctrine.connection.orm_default');\n    ```\n\n## Example configure container\n\n\u003eLaminas ServiceManager\n```php\nuse Streamcommon\\Doctrine\\Manager\\ConfigProvider;\nuse Laminas\\ServiceManager\\ServiceManager;\n\n$config = new ConfigProvider();\n$config = $config();\n$dependencies = $config['dependencies'];\n$dependencies['services']['config'] = $config;\nreturn new ServiceManager($dependencies);\n```\n\u003eSymfony Container\n```php\nuse JSoumelidis\\SymfonyDI\\Config\\{Config as SymfonyConfig, ContainerFactory as SymfonyContainerFactory};\nuse Streamcommon\\Doctrine\\Manager\\ConfigProvider;\n\n$config = new ConfigProvider();\n$config = $config();\n$dependencies = $config['dependencies'];\n$dependencies['services']['config'] = $config;\n$container = new SymfonyContainerFactory();\nreturn $container(new SymfonyConfig($dependencies))\n```\n\u003eEtc...\n\n## CLI usage\n1) See \n    - [doctrine orm console tools](https://www.doctrine-project.org/projects/doctrine-orm/en/2.6/reference/tools.html)\n    - [doctrine migrations console tools](https://www.doctrine-project.org/projects/doctrine-migrations/en/2.1/reference/introduction.html#introduction)\n2) For many connections was added a new `--object-manager` argument to `orm` namespace:\n```console\nArguments:\n  --object-manager      Doctrine object manager name [default: \"orm_default\"]\n```\n\n[Master branch]: https://github.com/streamcommon/doctrine-manager/tree/master\n[Master branch image]: https://img.shields.io/badge/branch-master-blue.svg\n[Develop branch]: https://github.com/streamcommon/doctrine-manager/tree/develop\n[Develop branch image]: https://img.shields.io/badge/branch-develop-blue.svg\n[Master image]: https://travis-ci.org/streamcommon/doctrine-manager.svg?branch=master\n[Master]: https://travis-ci.org/streamcommon/doctrine-manager\n[Master coverage image]: https://coveralls.io/repos/github/streamcommon/doctrine-manager/badge.svg?branch=master\n[Master coverage]: https://coveralls.io/github/streamcommon/doctrine-manager?branch=master\n[Develop image]: https://travis-ci.org/streamcommon/doctrine-manager.svg?branch=develop\n[Develop]: https://travis-ci.org/streamcommon/doctrine-manager\n[Develop coverage image]: https://coveralls.io/repos/github/streamcommon/doctrine-manager/badge.svg?branch=develop\n[Develop coverage]: https://coveralls.io/github/streamcommon/doctrine-manager?branch=develop","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstreamcommon%2Fdoctrine-manager","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstreamcommon%2Fdoctrine-manager","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstreamcommon%2Fdoctrine-manager/lists"}