{"action":"created","issue":{"url":"https://api.github.com/repos/slimphp/Slim/issues/1179","labels_url":"https://api.github.com/repos/slimphp/Slim/issues/1179/labels{/name}","comments_url":"https://api.github.com/repos/slimphp/Slim/issues/1179/comments","events_url":"https://api.github.com/repos/slimphp/Slim/issues/1179/events","html_url":"https://github.com/slimphp/Slim/pull/1179","id":69164306,"number":1179,"title":"[WIP] DIC independence","user":{"login":"akrabat","id":33135,"avatar_url":"https://avatars.githubusercontent.com/u/33135?v=3","gravatar_id":"","url":"https://api.github.com/users/akrabat","html_url":"https://github.com/akrabat","followers_url":"https://api.github.com/users/akrabat/followers","following_url":"https://api.github.com/users/akrabat/following{/other_user}","gists_url":"https://api.github.com/users/akrabat/gists{/gist_id}","starred_url":"https://api.github.com/users/akrabat/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/akrabat/subscriptions","organizations_url":"https://api.github.com/users/akrabat/orgs","repos_url":"https://api.github.com/users/akrabat/repos","events_url":"https://api.github.com/users/akrabat/events{/privacy}","received_events_url":"https://api.github.com/users/akrabat/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/slimphp/Slim/labels/improvement","name":"improvement","color":"ffea00"}],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/slimphp/Slim/milestones/12","html_url":"https://github.com/slimphp/Slim/milestones/Version%203.0.0","labels_url":"https://api.github.com/repos/slimphp/Slim/milestones/12/labels","id":382879,"number":12,"title":"Version 3.0.0","description":"","creator":{"login":"codeguy","id":31677,"avatar_url":"https://avatars.githubusercontent.com/u/31677?v=3","gravatar_id":"","url":"https://api.github.com/users/codeguy","html_url":"https://github.com/codeguy","followers_url":"https://api.github.com/users/codeguy/followers","following_url":"https://api.github.com/users/codeguy/following{/other_user}","gists_url":"https://api.github.com/users/codeguy/gists{/gist_id}","starred_url":"https://api.github.com/users/codeguy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/codeguy/subscriptions","organizations_url":"https://api.github.com/users/codeguy/orgs","repos_url":"https://api.github.com/users/codeguy/repos","events_url":"https://api.github.com/users/codeguy/events{/privacy}","received_events_url":"https://api.github.com/users/codeguy/received_events","type":"User","site_admin":false},"open_issues":7,"closed_issues":60,"state":"open","created_at":"2013-07-20T18:57:07Z","updated_at":"2015-04-18T21:24:41Z","due_on":null,"closed_at":null},"comments":8,"created_at":"2015-04-17T15:46:25Z","updated_at":"2015-04-20T00:31:41Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/slimphp/Slim/pulls/1179","html_url":"https://github.com/slimphp/Slim/pull/1179","diff_url":"https://github.com/slimphp/Slim/pull/1179.diff","patch_url":"https://github.com/slimphp/Slim/pull/1179.patch"},"body":"Slim now composes a ContainerInterface which it expects to be configured correctly. \r\n\r\n`App`'s constructor will accept either an array of user settings so that there is no change for the standard use-case or an instance of a `Interop\\Container\\ContainerInterface`.\r\n\r\ni.e you can either do:\r\n\r\n    $settings = [];\r\n    $app = new \\Slim\\App($settings);\r\n\r\nas normal, or you can do:\r\n\r\n    $settings = [];\r\n    $app = new \\Slim\\App(new \\My\\InteropContainer($settings));\r\n\r\n\r\nSee #1155 for initial discussion."},"comment":{"url":"https://api.github.com/repos/slimphp/Slim/issues/comments/94328618","html_url":"https://github.com/slimphp/Slim/pull/1179#issuecomment-94328618","issue_url":"https://api.github.com/repos/slimphp/Slim/issues/1179","id":94328618,"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":"2015-04-20T00:31:41Z","updated_at":"2015-04-20T00:31:41Z","body":"@Jusomeara please be aware that these benchmarks are skewed, have a look at the comments. Some containers should have a cache, or should be compiled, but the author didn't do it. Same for ZF2 he didn't benchmark the correct package. And the biggest problem is he's using a simple loop to benchmark. The truth is that benchmarking containers is unfortunately very difficult because a lot of things come into play (e.g. caches, opcache, autoloading, what is configured, etc.) and the time involved is very small. Putting some code in a loop doesn't work because autoloading, cache reads, etc have an impact (like in a real application where every new request starts from scratch). For a realistic test you have to benchmark through a web request (so that opcache works), but then response time are so fast (because you shouldn't use loops to make it artificially slower) that the HTTP + PHP init overhead is greater than the code execution. That should be doable though, but it takes some work and thinking :) (if anyone wants to try it I would be willing to help)\r\n\r\nIn any case I'm really happy with the direction this is all taking. I'd love to see PHP-DI in Slim, but I also think that container-interop is a very good option and would make Slim stand out (PSR-7 + container-interop makes a hell of a flexible architecture). Pimple is great for starting easily but becomes limited when the application grows. A different container would allow Slim applications to scale much more easily and create very complex applications.\r\n\r\nOf course Slim must come with a default container and work out of the box though ;) (whichever you decide to use)\r\n\r\nRegarding PHP-DI the v5 is currently in development and will be finished in a few weeks. I have been working on a new site + new documentation, it's still WIP but it's probably a little bit better than the current documentation: http://phpdi5.herokuapp.com/ (this URL is temporary)\r\n\r\nThe most important changes in v5 are:\r\n\r\n- lighter package, lighter defaults (less composer dependencies, annotations disabled by default, etc.)\r\n- simpler usage, syntactic sugar (i.e. if you are used to Pimple it will look familiar): http://phpdi5.herokuapp.com/news/14-php-di-5-syntaxic-sugar.html\r\n- support for modular systems (we're working on that for [Piwik](https://github.com/piwik/piwik) which has a plugin system): overriding or extending previous entries, lists, etc. (I can detail more if you are interested)\r\n\r\nI did a few performance tests yesterday with this branch using Pimple and PHP-DI, there's a small perf difference (15%) but it can be improved, I've already pushed some optimizations (v5 is not polished yet).\r\n\r\nI have done a little Silex + PHP-DI integration, and I'd love to push it further with Slim (either through official support, or a PHP-DI integration). In any case I would love to help and get involved in Slim, and if you have suggestions for improving PHP-DI (new features…) the v5 it is still open.\r\n\r\nNow regarding this pull request, it is really great. I also thought about a few things:\r\n\r\n- I wouldn't put the request and response factories in the container: those are only helpers used by the `App` class, so I would move them to private `createRequest()` and `createResponse()` methods\r\n- I would document somewhere the container entries (or \"services\") that Slim expect to be registered in the container: that way user it is easier to know what to define in containers for Slim to work\r\n- a way to keep the simple API of Pimple would be to have `App` implement `ArrayAccess`, and redirect to the container - of course that wouldn't work with `offsetSet` in which case an exception would be thrown (or it could work only with Pimple…). That means the interface is not fully implemented, but the convenience is kept. It's just an idea, I'm not too sure about that myself…\r\n\r\nI have another suggestion about dependency injection too but my comment is getting big, I'll open a separate issue ;)"}}