{"action":"created","issue":{"url":"https://api.github.com/repos/yiisoft/yii2/issues/8911","repository_url":"https://api.github.com/repos/yiisoft/yii2","labels_url":"https://api.github.com/repos/yiisoft/yii2/issues/8911/labels{/name}","comments_url":"https://api.github.com/repos/yiisoft/yii2/issues/8911/comments","events_url":"https://api.github.com/repos/yiisoft/yii2/issues/8911/events","html_url":"https://github.com/yiisoft/yii2/issues/8911","id":91218211,"number":8911,"title":"Dependency Injection: contextual binding","user":{"login":"akireikin","id":2033719,"avatar_url":"https://avatars.githubusercontent.com/u/2033719?v=3","gravatar_id":"","url":"https://api.github.com/users/akireikin","html_url":"https://github.com/akireikin","followers_url":"https://api.github.com/users/akireikin/followers","following_url":"https://api.github.com/users/akireikin/following{/other_user}","gists_url":"https://api.github.com/users/akireikin/gists{/gist_id}","starred_url":"https://api.github.com/users/akireikin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/akireikin/subscriptions","organizations_url":"https://api.github.com/users/akireikin/orgs","repos_url":"https://api.github.com/users/akireikin/repos","events_url":"https://api.github.com/users/akireikin/events{/privacy}","received_events_url":"https://api.github.com/users/akireikin/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/yiisoft/yii2/labels/type:enhancement","name":"type:enhancement","color":"d7e102"}],"state":"closed","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/yiisoft/yii2/milestones/9","html_url":"https://github.com/yiisoft/yii2/milestones/2.0.x","labels_url":"https://api.github.com/repos/yiisoft/yii2/milestones/9/labels","id":831720,"number":9,"title":"2.0.x","description":"","creator":{"login":"cebe","id":189796,"avatar_url":"https://avatars.githubusercontent.com/u/189796?v=3","gravatar_id":"","url":"https://api.github.com/users/cebe","html_url":"https://github.com/cebe","followers_url":"https://api.github.com/users/cebe/followers","following_url":"https://api.github.com/users/cebe/following{/other_user}","gists_url":"https://api.github.com/users/cebe/gists{/gist_id}","starred_url":"https://api.github.com/users/cebe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cebe/subscriptions","organizations_url":"https://api.github.com/users/cebe/orgs","repos_url":"https://api.github.com/users/cebe/repos","events_url":"https://api.github.com/users/cebe/events{/privacy}","received_events_url":"https://api.github.com/users/cebe/received_events","type":"User","site_admin":false},"open_issues":383,"closed_issues":1,"state":"open","created_at":"2014-10-19T13:49:45Z","updated_at":"2016-02-07T08:14:32Z","due_on":null,"closed_at":null},"comments":14,"created_at":"2015-06-26T10:32:58Z","updated_at":"2016-02-07T08:14:32Z","closed_at":"2016-02-07T08:14:32Z","body":"Is it possible to set contextual binding like [here](http://laravel.com/docs/5.0/container#contextual-binding)?\r\n\r\n```php\r\ninterface SomeInterface {}\r\nclass A implements SomeInterface {}\r\nclass B implements SomeInterface {}\r\n\r\nclass SomeClass\r\n{\r\n    private $x;\r\n\r\n    public function __construct(SomeInterface $x)\r\n    {\r\n        $this->x = $x;\r\n    }\r\n\r\n    public function whoIsX()\r\n    {\r\n        echo get_class($this->x);\r\n    }\r\n}\r\n\r\nclass ContextA extends SomeClass {}\r\nclass ContextB extends SomeClass {}\r\n\r\n$container = new \\yii\\di\\Container();\r\n\r\n// ??? contextual binding ???\r\n\r\n// A\r\n$container->get(ContextA::class)->whoIsX();\r\n\r\n// B\r\n$container->get(ContextB::class)->whoIsX();\r\n\r\n\r\n```"},"comment":{"url":"https://api.github.com/repos/yiisoft/yii2/issues/comments/180974335","html_url":"https://github.com/yiisoft/yii2/issues/8911#issuecomment-180974335","issue_url":"https://api.github.com/repos/yiisoft/yii2/issues/8911","id":180974335,"user":{"login":"samdark","id":47294,"avatar_url":"https://avatars.githubusercontent.com/u/47294?v=3","gravatar_id":"","url":"https://api.github.com/users/samdark","html_url":"https://github.com/samdark","followers_url":"https://api.github.com/users/samdark/followers","following_url":"https://api.github.com/users/samdark/following{/other_user}","gists_url":"https://api.github.com/users/samdark/gists{/gist_id}","starred_url":"https://api.github.com/users/samdark/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/samdark/subscriptions","organizations_url":"https://api.github.com/users/samdark/orgs","repos_url":"https://api.github.com/users/samdark/repos","events_url":"https://api.github.com/users/samdark/events{/privacy}","received_events_url":"https://api.github.com/users/samdark/received_events","type":"User","site_admin":false},"created_at":"2016-02-07T08:14:32Z","updated_at":"2016-02-07T08:14:32Z","body":"Not going to accept it. It's way too magical. Makes reading code and debugging it very hard."}}