{"action":"created","issue":{"url":"https://api.github.com/repos/thephpleague/route/issues/37","labels_url":"https://api.github.com/repos/thephpleague/route/issues/37/labels{/name}","comments_url":"https://api.github.com/repos/thephpleague/route/issues/37/comments","events_url":"https://api.github.com/repos/thephpleague/route/issues/37/events","html_url":"https://github.com/thephpleague/route/issues/37","id":65337276,"number":37,"title":"Request alias is not identified in the container with RestfulStrategy","user":{"login":"shadowhand","id":38203,"avatar_url":"https://avatars.githubusercontent.com/u/38203?v=3","gravatar_id":"","url":"https://api.github.com/users/shadowhand","html_url":"https://github.com/shadowhand","followers_url":"https://api.github.com/users/shadowhand/followers","following_url":"https://api.github.com/users/shadowhand/following{/other_user}","gists_url":"https://api.github.com/users/shadowhand/gists{/gist_id}","starred_url":"https://api.github.com/users/shadowhand/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shadowhand/subscriptions","organizations_url":"https://api.github.com/users/shadowhand/orgs","repos_url":"https://api.github.com/users/shadowhand/repos","events_url":"https://api.github.com/users/shadowhand/events{/privacy}","received_events_url":"https://api.github.com/users/shadowhand/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-03-31T00:53:49Z","updated_at":"2015-03-31T00:54:08Z","closed_at":null,"body":"I am using `league/container` in my project and have this code to set up my container:\r\n\r\n```php\r\n$container->add('Router', function () use ($container) {\r\n    $router = new RouteCollection($container);\r\n    $router->setStrategy(new RestfulStrategy);\r\n    // ... list of routes\r\n    return $router;\r\n});\r\n```\r\n\r\nAnd then this code to dispatch the request:\r\n\r\n```php\r\n$router     = $container->get('Router');\r\n$request    = $container->get('Request');\r\n$dispatcher = $router->getDispatcher();\r\n$response   = $dispatcher->dispatch($request->getMethod(), $request->getPathInfo());\r\n```\r\n\r\nThe problem is that when my controllers are called with `action($request)` the request is a new instance and not the request that was used to dispatch. I would suggest adding a method to `RestfulStrategy` that would allow the request name to be set:\r\n\r\n```php\r\npublic function setRequest($request) { ... }\r\npublic function getRequest() { ... }\r\n\r\npublic function dispatch($controller, array $vars)\r\n{\r\n    // ...\r\n    $request = $this->getRequest() ?: $this->getContainer()->get(...);\r\n    // ...\r\n}\r\n```\r\n\r\nThis would allow me to do the following, without having to use a FQCN in my container:\r\n\r\n```php\r\n$container->set('DispatchStrategy', RestfulStrategy::class)\r\n    ->withMethodCall('setRequest', ['Request']);\r\n```"},"comment":{"url":"https://api.github.com/repos/thephpleague/route/issues/comments/87889618","html_url":"https://github.com/thephpleague/route/issues/37#issuecomment-87889618","issue_url":"https://api.github.com/repos/thephpleague/route/issues/37","id":87889618,"user":{"login":"shadowhand","id":38203,"avatar_url":"https://avatars.githubusercontent.com/u/38203?v=3","gravatar_id":"","url":"https://api.github.com/users/shadowhand","html_url":"https://github.com/shadowhand","followers_url":"https://api.github.com/users/shadowhand/followers","following_url":"https://api.github.com/users/shadowhand/following{/other_user}","gists_url":"https://api.github.com/users/shadowhand/gists{/gist_id}","starred_url":"https://api.github.com/users/shadowhand/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shadowhand/subscriptions","organizations_url":"https://api.github.com/users/shadowhand/orgs","repos_url":"https://api.github.com/users/shadowhand/repos","events_url":"https://api.github.com/users/shadowhand/events{/privacy}","received_events_url":"https://api.github.com/users/shadowhand/received_events","type":"User","site_admin":false},"created_at":"2015-03-31T00:54:08Z","updated_at":"2015-03-31T00:54:08Z","body":"See also #26."}}