{"action":"created","issue":{"url":"https://api.github.com/repos/symfony/symfony/issues/17548","labels_url":"https://api.github.com/repos/symfony/symfony/issues/17548/labels{/name}","comments_url":"https://api.github.com/repos/symfony/symfony/issues/17548/comments","events_url":"https://api.github.com/repos/symfony/symfony/issues/17548/events","html_url":"https://github.com/symfony/symfony/issues/17548","id":128884122,"number":17548,"title":" Dependency Injection: 'simple injection' or @service_container","user":{"login":"nietzcheson","id":1699198,"avatar_url":"https://avatars.githubusercontent.com/u/1699198?v=3","gravatar_id":"","url":"https://api.github.com/users/nietzcheson","html_url":"https://github.com/nietzcheson","followers_url":"https://api.github.com/users/nietzcheson/followers","following_url":"https://api.github.com/users/nietzcheson/following{/other_user}","gists_url":"https://api.github.com/users/nietzcheson/gists{/gist_id}","starred_url":"https://api.github.com/users/nietzcheson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nietzcheson/subscriptions","organizations_url":"https://api.github.com/users/nietzcheson/orgs","repos_url":"https://api.github.com/users/nietzcheson/repos","events_url":"https://api.github.com/users/nietzcheson/events{/privacy}","received_events_url":"https://api.github.com/users/nietzcheson/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-01-26T17:19:05Z","updated_at":"2016-01-26T18:16:10Z","closed_at":null,"body":"Hi all. A greeting. \r\n\r\nI do not know where is the place to do it . But I want to share it and discuss it.\r\n\r\nI doubt has arisen . We know the great power of the injection of dependencies within the program ( and Symfony).\r\n\r\nWhat followed? In Symfony I can create a service and injecting it into another . But I can also inject the service_container and have all services in a single variable. Does this last sentence the application performance ? Is it advisable to use only the services I need ?\r\n\r\n```yml\r\n\r\nservices:\r\n  service:\r\n    class: AppBundle\\Service;\r\n  \r\n  service.utils:\r\n    class: AppBundle\\ServiceUtils;\r\n    arguments:\r\n      - @service\r\n\r\nservice.container:\r\n    class: AppBundle\\ServiceContainer;\r\n    calls:\r\n      - [setContainer, [‘@service_container']]\r\n\r\n```\r\n\r\nCheers..."},"comment":{"url":"https://api.github.com/repos/symfony/symfony/issues/comments/175152341","html_url":"https://github.com/symfony/symfony/issues/17548#issuecomment-175152341","issue_url":"https://api.github.com/repos/symfony/symfony/issues/17548","id":175152341,"user":{"login":"stof","id":439401,"avatar_url":"https://avatars.githubusercontent.com/u/439401?v=3","gravatar_id":"","url":"https://api.github.com/users/stof","html_url":"https://github.com/stof","followers_url":"https://api.github.com/users/stof/followers","following_url":"https://api.github.com/users/stof/following{/other_user}","gists_url":"https://api.github.com/users/stof/gists{/gist_id}","starred_url":"https://api.github.com/users/stof/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stof/subscriptions","organizations_url":"https://api.github.com/users/stof/orgs","repos_url":"https://api.github.com/users/stof/repos","events_url":"https://api.github.com/users/stof/events{/privacy}","received_events_url":"https://api.github.com/users/stof/received_events","type":"User","site_admin":false},"created_at":"2016-01-26T18:16:10Z","updated_at":"2016-01-26T18:16:10Z","body":"Injecting the whole container means that your class now depends on the whole world. This makes it very hard to test (you have to initialize or mock the whole container), makes it very hard to know what it really uses (you have to investigate the whole code), etc...\r\n\r\nIt is generally a bad idea to do this. It is much better to inject only what you need (you will see it when you will start writing tests).\r\nNote that in 2.8+ autowiring might help you."}}