title: php MongoDB\Driver\Manager not found when executing Symfony command
body: <p>Ok, so I have a project my mongo connection works fine when viewing pages etc. But when I try to load the manage class in command (ContainerAwareCommand) I get class not found exception: </p>
  
  <p>[Symfony\Component\Debug\Exception\ClassNotFoundException]<br>
    Attempted to load class "Manager" from namespace "MongoDB\Driver".<br>
    Did you forget a "use" statement for another namespace? </p>
  
  <p>I'm using symfony 3.2</p>
  
  <p>Here's what I do:</p>
  
  <pre><code>class TestCommand extends ContainerAwareCommand {
     protected function configure() {
        $this-&gt;setName('testcommand:test')
          -&gt;setDescription('Test...')
          -&gt;setHelp('Test...');
     }
  
   protected function execute(InputInterface $input, OutputInterface   $output) {
      $db = new Manager("mongodb://localhost:27017");
      $output-&gt;writeln([
          'Test',
          '========================',
          '',
      ]);
    }
   }
  </code></pre>
  
  <p>I import the driver with:</p>
  
  <pre><code>use MongoDB\Driver\Manager;
  </code></pre>
  
  <p>PhpStorm recognizes the import.</p>
  
  <p>Any ideas what stops the class from loading? Once again, it loads normally when I navigate my pages etc.</p>
  
  <p>Thanks!</p>
  
  <p>UPDATE (As requested) !</p>
  
  <p>Registered a service: </p>
  
  <pre><code>services:
    test.service:
      class: AppBundle\Test\TestService
      public: true
  </code></pre>
  
  <p>The service: </p>
  
  <pre><code>namespace AppBundle\Test;
  
  
  use MongoDB\Driver\Manager;
  
  class TestService {
  
     public function foo() {
        $manager = new Manager("mongodb://localhost:27017");
     }
  }
  </code></pre>
  
  <p>added this to execute method:</p>
  
  <pre><code>$ts = $this-&gt;getContainer()-&gt;get("test.service");
  $ts-&gt;foo();
  </code></pre>
  
  <p>result: </p>
  
  <p>[Symfony\Component\Debug\Exception\ClassNotFoundException]<br>
    Attempted to load class "Manager" from namespace "MongoDB\Driver".<br>
    Did you forget a "use" statement for another namespace? </p>
  
  <p>What am I missing?</p>
  
  <p>ANOTHER UPDATE</p>
  
  <p>I also noticed that I couldn't switch to production because of the same, but more general, error.</p>
  
  <p>Turns out I can't use namespaces but can get the class (Manager) via fully qualified name at RUN TIME ONLY!!!</p>