{"action":"created","issue":{"url":"https://api.github.com/repos/symfony/symfony/issues/18355","repository_url":"https://api.github.com/repos/symfony/symfony","labels_url":"https://api.github.com/repos/symfony/symfony/issues/18355/labels{/name}","comments_url":"https://api.github.com/repos/symfony/symfony/issues/18355/comments","events_url":"https://api.github.com/repos/symfony/symfony/issues/18355/events","html_url":"https://github.com/symfony/symfony/issues/18355","id":144388030,"number":18355,"title":"Using Request retrieved through RequestStack in CLI throws FileLoaderLoadException with routing.yml as target","user":{"login":"IckleChris","id":3933176,"avatar_url":"https://avatars.githubusercontent.com/u/3933176?v=3","gravatar_id":"","url":"https://api.github.com/users/IckleChris","html_url":"https://github.com/IckleChris","followers_url":"https://api.github.com/users/IckleChris/followers","following_url":"https://api.github.com/users/IckleChris/following{/other_user}","gists_url":"https://api.github.com/users/IckleChris/gists{/gist_id}","starred_url":"https://api.github.com/users/IckleChris/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/IckleChris/subscriptions","organizations_url":"https://api.github.com/users/IckleChris/orgs","repos_url":"https://api.github.com/users/IckleChris/repos","events_url":"https://api.github.com/users/IckleChris/events{/privacy}","received_events_url":"https://api.github.com/users/IckleChris/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/symfony/symfony/labels/Bug","name":"Bug","color":"e10c02"},{"url":"https://api.github.com/repos/symfony/symfony/labels/Status:%20Needs%20Review","name":"Status: Needs Review","color":"ededed"},{"url":"https://api.github.com/repos/symfony/symfony/labels/Unconfirmed","name":"Unconfirmed","color":"444444"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":9,"created_at":"2016-03-29T21:05:15Z","updated_at":"2016-03-30T10:24:59Z","closed_at":"2016-03-30T09:09:24Z","body":"For context I'm running Symfony 3.0.3 utilising FOSRestBundle 1.7.7.\r\n\r\nI've just finished debugging the following `FileLoaderLoadException`, which was thrown whenever the `cache:clear` or `debug:router` commands where run (but not when using the application in the browser);\r\n\r\n`[Symfony\\Component\\Config\\Exception\\FileLoaderLoadException]\r\n  Notice: Trying to get property of non-object in Path/To/Application/src/BundleName/Resources/config/routing.yml (which is being imported from \"Path/To/Application/app/config/routing.yml\").`\r\n\r\nAfter following through from the command the issue ended up lying in my application's custom Base Controller (which is extended by all resource controllers, which are defined as services) which calls the following two lines from the constructor;\r\n\r\n```php\r\n// ...\r\n$this->request = $requestStack->getCurrentRequest();\r\n$this->expandResponse = (bool)$this->request->query->get('expand', false);\r\n// ...\r\n```\r\n\r\nIn the context of the CLI command `$this->request` was being set to null, which therefore caused the Exception to be thrown in the following line. It was however confusing having the exception refer to the `routing.yml` file as the source of the issue. To fix the issue I've wrapped the above code with `if ($requestStack->getCurrentRequest()) { ... }`. \r\n\r\nCan/should the exception be made clearer in this case?"},"comment":{"url":"https://api.github.com/repos/symfony/symfony/issues/comments/203369546","html_url":"https://github.com/symfony/symfony/issues/18355#issuecomment-203369546","issue_url":"https://api.github.com/repos/symfony/symfony/issues/18355","id":203369546,"user":{"login":"xabbuh","id":1957048,"avatar_url":"https://avatars.githubusercontent.com/u/1957048?v=3","gravatar_id":"","url":"https://api.github.com/users/xabbuh","html_url":"https://github.com/xabbuh","followers_url":"https://api.github.com/users/xabbuh/followers","following_url":"https://api.github.com/users/xabbuh/following{/other_user}","gists_url":"https://api.github.com/users/xabbuh/gists{/gist_id}","starred_url":"https://api.github.com/users/xabbuh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xabbuh/subscriptions","organizations_url":"https://api.github.com/users/xabbuh/orgs","repos_url":"https://api.github.com/users/xabbuh/repos","events_url":"https://api.github.com/users/xabbuh/events{/privacy}","received_events_url":"https://api.github.com/users/xabbuh/received_events","type":"User","site_admin":false},"created_at":"2016-03-30T10:24:59Z","updated_at":"2016-03-30T10:24:59Z","body":"@iltar Throwing an exception in `getCurrentRequest()` would be a BC break (note that we explicitly document that the method might return `null`)."}}