symfony/symfony-docs — Issue #890: [Cookbook] [CLI] Getting Services from the Service Container example does not work
Author: jonathaningram
Created: 2011-11-27 23:20:59+00:00
State: open

I am troubleshooting the annoying `You cannot create a service ("request") of an inactive scope ("request"). ` CLI error, and I checked the docs to see if they successfully used the translator in a command. I found the following example, but it appears to fail with the same error too, so I propose either a) fix the example so that it works (thus helping me too ;) ) or b) changing the example to retrieve a different service that does not depend on the `request`.

```php
getArgument('name');
$translator = $this->getContainer()->get('translator');
if ($name) {
$output->writeln($translator->trans('Hello %name%!', array('%name%' => $name)));
} else {
$output->writeln($translator->trans('Hello!'));
}
}
```

The doc URL is [here](http://symfony.com/doc/2.0/cookbook/console.html)