{"action":"created","issue":{"url":"https://api.github.com/repos/PHP-DI/PHP-DI/issues/363","repository_url":"https://api.github.com/repos/PHP-DI/PHP-DI","labels_url":"https://api.github.com/repos/PHP-DI/PHP-DI/issues/363/labels{/name}","comments_url":"https://api.github.com/repos/PHP-DI/PHP-DI/issues/363/comments","events_url":"https://api.github.com/repos/PHP-DI/PHP-DI/issues/363/events","html_url":"https://github.com/PHP-DI/PHP-DI/issues/363","id":125574672,"number":363,"title":"Stance on standardized DI definition / configuration snippets","user":{"login":"holtkamp","id":776405,"avatar_url":"https://avatars.githubusercontent.com/u/776405?v=3","gravatar_id":"","url":"https://api.github.com/users/holtkamp","html_url":"https://github.com/holtkamp","followers_url":"https://api.github.com/users/holtkamp/followers","following_url":"https://api.github.com/users/holtkamp/following{/other_user}","gists_url":"https://api.github.com/users/holtkamp/gists{/gist_id}","starred_url":"https://api.github.com/users/holtkamp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/holtkamp/subscriptions","organizations_url":"https://api.github.com/users/holtkamp/orgs","repos_url":"https://api.github.com/users/holtkamp/repos","events_url":"https://api.github.com/users/holtkamp/events{/privacy}","received_events_url":"https://api.github.com/users/holtkamp/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/PHP-DI/PHP-DI/labels/enhancement","name":"enhancement","color":"009800"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":8,"created_at":"2016-01-08T09:30:50Z","updated_at":"2016-03-15T21:25:12Z","closed_at":"2016-03-15T21:25:12Z","body":"Recently I used PHP-DI to replace some parts of a Zend Framework 1 application:\r\n\r\n- [Bisna container](https://github.com/guilhermeblanco/zendframework1-doctrine2), that was used to configure Doctrine ORM and ODM\r\n- Zend Cache Manager, switched to [doctrine/cache](https://github.com/doctrine/cache)\r\n\r\nThis went quite smooth and it made me think of how to 'standardize' such configurations. \r\n\r\nFor example, this definition snippet sets up a MongoDB connection with a default collection:\r\n\r\n```php\r\nreturn array(\r\n    MongoClient::class => object()->constructor(get('setting.mongodb.url'), $options = array()),\r\n    MongoDB::class => object()->constructor(get(MongoClient::class), get('setting.mongodb.database')),\r\n    MongoCollection::class => object()->constructor(get(MongoDB::class), $name = 'DefaultCollection'),\r\n)\r\n```\r\n\r\nAnd this can be used to easily set op Doctrine Caches that use a chained approach and a wildcard approach for ease of use: $container->get('ORMAnnotationCacheProvider'):\r\n\r\n```php\r\nreturn array(\r\n    'chainCachesCollection' => array(\r\n        get(Doctrine\\Common\\Cache\\ArrayCache::class),\r\n        get(Doctrine\\Common\\Cache\\ApcuCache::class),\r\n        get(Doctrine\\Common\\Cache\\MongoDBCache::class),\r\n    ),\r\n    Doctrine\\Common\\Cache\\ArrayCache::class => object()->constructor(),\r\n    Doctrine\\Common\\Cache\\ApcuCache::class => object()->constructor(),\r\n    Doctrine\\Common\\Cache\\MongoDBCache::class => object()->constructor(get(MongoCollection::class)),\r\n    Doctrine\\Common\\Cache\\ChainCache::class => object()->constructor(get('chainCachesCollection')),\r\n    '*CacheProvider' => function (Doctrine\\Common\\Cache\\ChainCache $chainCache, RequestedEntry $e) {\r\n        $chainCache->setNamespace($e->getName());\r\n        return $chainCache;\r\n    },\r\n);\r\n```\r\n\r\nWould it be an idea to set up a repository to collect such snippets? It is not 'really' a 'bridge', more an application agnostic configuration... Does https://github.com/container-interop/container-interop intend to develop standardized DI configuration approaches as well?\r\n"},"comment":{"url":"https://api.github.com/repos/PHP-DI/PHP-DI/issues/comments/197026280","html_url":"https://github.com/PHP-DI/PHP-DI/issues/363#issuecomment-197026280","issue_url":"https://api.github.com/repos/PHP-DI/PHP-DI/issues/363","id":197026280,"user":{"login":"mnapoli","id":720328,"avatar_url":"https://avatars.githubusercontent.com/u/720328?v=3","gravatar_id":"","url":"https://api.github.com/users/mnapoli","html_url":"https://github.com/mnapoli","followers_url":"https://api.github.com/users/mnapoli/followers","following_url":"https://api.github.com/users/mnapoli/following{/other_user}","gists_url":"https://api.github.com/users/mnapoli/gists{/gist_id}","starred_url":"https://api.github.com/users/mnapoli/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mnapoli/subscriptions","organizations_url":"https://api.github.com/users/mnapoli/orgs","repos_url":"https://api.github.com/users/mnapoli/repos","events_url":"https://api.github.com/users/mnapoli/events{/privacy}","received_events_url":"https://api.github.com/users/mnapoli/received_events","type":"User","site_admin":false},"created_at":"2016-03-15T21:25:12Z","updated_at":"2016-03-15T21:25:12Z","body":"For the record we have been working for some time on https://github.com/container-interop/service-provider now, feel free to give it a look. We'll share it on the FIG's mailing list in a few days.\r\n\r\nI think this issue can be closed as it's not really part of this project."}}