title: Doctrine schema tool create command fails - ReflectionException Class does not exist
body: <p>We're using Doctrine YAML files to generate our entities. When I run <code>../../vendor/bin/doctrine orm:generate-entities src</code> from the folder where my <code>bootstrap.php</code> and <code>cli-config.php</code> is it appears to generate the PHP entity classes correctly:</p>
  
  <pre><code>../../vendor/bin/doctrine orm:generate-entities src
  Generating Doctrine entities...
  Processing entity "Entity\BucketGroup"
  Processing entity "Entity\Cheat"
  Processing entity "Entity\Content"
  Processing entity "Entity\ContentGroup"
  Processing entity "Entity\ContentType"
  Processing entity "Entity\Developer"
  Processing entity "Entity\ExternalIdentityProvider"
  Processing entity "Entity\Game"
  Processing entity "Entity\GameRelease"
  Processing entity "Entity\Genre"
  Processing entity "Entity\HighlightedContent"
  Processing entity "Entity\Media"
  Processing entity "Entity\MediaGroup"
  Processing entity "Entity\Platform"
  Processing entity "Entity\ProsAndCons"
  Processing entity "Entity\Publisher"
  Processing entity "Entity\Rating"
  Processing entity "Entity\Region"
  Processing entity "Entity\Site"
  Processing entity "Entity\Tag"
  Processing entity "Entity\User"
  Processing entity "Entity\UserExternalIdentityProvider"
  Processing entity "Entity\VideoAdvert"
  </code></pre>
  
  <p>Next when I run <code>../../vendor/bin/doctrine orm:schema-tool:create</code> I get the following PHP error stack trace:</p>
  
  <pre><code>PHP Warning:  class_parents(): Class Entity\BucketGroup does not exist and could not be loaded in /vagrant/www/creo.api/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/RuntimeReflectionService.php on line 40
  PHP Stack trace:
  PHP   1. {main}() /vagrant/www/creo.api/vendor/doctrine/orm/bin/doctrine:0
  PHP   2. include() /vagrant/www/creo.api/vendor/doctrine/orm/bin/doctrine:4
  PHP   3. Doctrine\ORM\Tools\Console\ConsoleRunner::run() /vagrant/www/creo.api/vendor/doctrine/orm/bin/doctrine.php:43
  PHP   4. Symfony\Component\Console\Application-&gt;run() /vagrant/www/creo.api/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Console/ConsoleRunner.php:41
  PHP   5. Symfony\Component\Console\Application-&gt;doRun() /vagrant/www/creo.api/vendor/symfony/console/Symfony/Component/Console/Application.php:121
  PHP   6. Symfony\Component\Console\Application-&gt;doRunCommand() /vagrant/www/creo.api/vendor/symfony/console/Symfony/Component/Console/Application.php:191
  PHP   7. Symfony\Component\Console\Command\Command-&gt;run() /vagrant/www/creo.api/vendor/symfony/console/Symfony/Component/Console/Application.php:899
  PHP   8. Doctrine\ORM\Tools\Console\Command\SchemaTool\AbstractCommand-&gt;execute() /vagrant/www/creo.api/vendor/symfony/console/Symfony/Component/Console/Command/Command.php:244
  PHP   9. Doctrine\Common\Persistence\Mapping\AbstractClassMetadataFactory-&gt;getAllMetadata() /vagrant/www/creo.api/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Console/Command/SchemaTool/AbstractCommand.php:47
  PHP  10. Doctrine\Common\Persistence\Mapping\AbstractClassMetadataFactory-&gt;getMetadataFor() /vagrant/www/creo.api/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/AbstractClassMetadataFactory.php:112
  PHP  11. Doctrine\Common\Persistence\Mapping\AbstractClassMetadataFactory-&gt;loadMetadata() /vagrant/www/creo.api/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/AbstractClassMetadataFactory.php:205
  PHP  12. Doctrine\Common\Persistence\Mapping\AbstractClassMetadataFactory-&gt;getParentClasses() /vagrant/www/creo.api/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/AbstractClassMetadataFactory.php:281
  PHP  13. Doctrine\Common\Persistence\Mapping\RuntimeReflectionService-&gt;getParentClasses() /vagrant/www/creo.api/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/AbstractClassMetadataFactory.php:257
  PHP  14. class_parents() /vagrant/www/creo.api/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/RuntimeReflectionService.php:40
  PHP Warning:  array_reverse() expects parameter 1 to be array, boolean given in /vagrant/www/creo.api/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/AbstractClassMetadataFactory.php on line 257
  PHP Stack trace:
  PHP   1. {main}() /vagrant/www/creo.api/vendor/doctrine/orm/bin/doctrine:0
  PHP   2. include() /vagrant/www/creo.api/vendor/doctrine/orm/bin/doctrine:4
  PHP   3. Doctrine\ORM\Tools\Console\ConsoleRunner::run() /vagrant/www/creo.api/vendor/doctrine/orm/bin/doctrine.php:43
  PHP   4. Symfony\Component\Console\Application-&gt;run() /vagrant/www/creo.api/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Console/ConsoleRunner.php:41
  PHP   5. Symfony\Component\Console\Application-&gt;doRun() /vagrant/www/creo.api/vendor/symfony/console/Symfony/Component/Console/Application.php:121
  PHP   6. Symfony\Component\Console\Application-&gt;doRunCommand() /vagrant/www/creo.api/vendor/symfony/console/Symfony/Component/Console/Application.php:191
  PHP   7. Symfony\Component\Console\Command\Command-&gt;run() /vagrant/www/creo.api/vendor/symfony/console/Symfony/Component/Console/Application.php:899
  PHP   8. Doctrine\ORM\Tools\Console\Command\SchemaTool\AbstractCommand-&gt;execute() /vagrant/www/creo.api/vendor/symfony/console/Symfony/Component/Console/Command/Command.php:244
  PHP   9. Doctrine\Common\Persistence\Mapping\AbstractClassMetadataFactory-&gt;getAllMetadata() /vagrant/www/creo.api/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Console/Command/SchemaTool/AbstractCommand.php:47
  PHP  10. Doctrine\Common\Persistence\Mapping\AbstractClassMetadataFactory-&gt;getMetadataFor() /vagrant/www/creo.api/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/AbstractClassMetadataFactory.php:112
  PHP  11. Doctrine\Common\Persistence\Mapping\AbstractClassMetadataFactory-&gt;loadMetadata() /vagrant/www/creo.api/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/AbstractClassMetadataFactory.php:205
  PHP  12. Doctrine\Common\Persistence\Mapping\AbstractClassMetadataFactory-&gt;getParentClasses() /vagrant/www/creo.api/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/AbstractClassMetadataFactory.php:281
  PHP  13. array_reverse() /vagrant/www/creo.api/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/AbstractClassMetadataFactory.php:257
  PHP Warning:  Invalid argument supplied for foreach() in /vagrant/www/creo.api/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/AbstractClassMetadataFactory.php on line 257
  PHP Stack trace:
  PHP   1. {main}() /vagrant/www/creo.api/vendor/doctrine/orm/bin/doctrine:0
  PHP   2. include() /vagrant/www/creo.api/vendor/doctrine/orm/bin/doctrine:4
  PHP   3. Doctrine\ORM\Tools\Console\ConsoleRunner::run() /vagrant/www/creo.api/vendor/doctrine/orm/bin/doctrine.php:43
  PHP   4. Symfony\Component\Console\Application-&gt;run() /vagrant/www/creo.api/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Console/ConsoleRunner.php:41
  PHP   5. Symfony\Component\Console\Application-&gt;doRun() /vagrant/www/creo.api/vendor/symfony/console/Symfony/Component/Console/Application.php:121
  PHP   6. Symfony\Component\Console\Application-&gt;doRunCommand() /vagrant/www/creo.api/vendor/symfony/console/Symfony/Component/Console/Application.php:191
  PHP   7. Symfony\Component\Console\Command\Command-&gt;run() /vagrant/www/creo.api/vendor/symfony/console/Symfony/Component/Console/Application.php:899
  PHP   8. Doctrine\ORM\Tools\Console\Command\SchemaTool\AbstractCommand-&gt;execute() /vagrant/www/creo.api/vendor/symfony/console/Symfony/Component/Console/Command/Command.php:244
  PHP   9. Doctrine\Common\Persistence\Mapping\AbstractClassMetadataFactory-&gt;getAllMetadata() /vagrant/www/creo.api/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Console/Command/SchemaTool/AbstractCommand.php:47
  PHP  10. Doctrine\Common\Persistence\Mapping\AbstractClassMetadataFactory-&gt;getMetadataFor() /vagrant/www/creo.api/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/AbstractClassMetadataFactory.php:112
  PHP  11. Doctrine\Common\Persistence\Mapping\AbstractClassMetadataFactory-&gt;loadMetadata() /vagrant/www/creo.api/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/AbstractClassMetadataFactory.php:205
  PHP  12. Doctrine\Common\Persistence\Mapping\AbstractClassMetadataFactory-&gt;getParentClasses() /vagrant/www/creo.api/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/AbstractClassMetadataFactory.php:281
  
  
  
  [ReflectionException]
  Class Entity\BucketGroup does not exist
  </code></pre>
  
  <p>The BucketGroup PHP entity file is definitely be created correctly and is correctly namespaced.</p>
  
  <p>For reference is my <code>bootstrap.php</code> file:</p>
  
  <pre><code>&lt;?php
  
  use Doctrine\ORM\Tools\Setup;
  use Doctrine\ORM\EntityManager;
  
  include '../../vendor/autoload.php';
  
  $isDevMode = true;
  
  $config = Setup::createYAMLMetadataConfiguration([__DIR__ . '/config/yaml'], $isDevMode);
  
  // The included file is generated by db-generate-schema Chef recipe and include the DB connection parameters in an array called $conn
  include ('dbgenerate.php');
  
  $entityManager = EntityManager::create($conn, $config);
  </code></pre>
  
  <p>and here is my <code>cli-config.php</code> file:</p>
  
  <pre><code>&lt;?php
  
  include __DIR__ . '/bootstrap.php';
  
  $entityManager-&gt;getConnection()
                -&gt;getDatabasePlatform()
                -&gt;registerDoctrineTypeMapping('enum', 'string');
  
  $helperSet = new \Symfony\Component\Console\Helper\HelperSet([
      'db' =&gt; new \Doctrine\DBAL\Tools\Console\Helper\ConnectionHelper($entityManager-&gt;getConnection()),
      'em' =&gt; new \Doctrine\ORM\Tools\Console\Helper\EntityManagerHelper($entityManager)
  ]);
  </code></pre>
  
  <p>I'm using the latest version of Doctrine loaded via Composer (2.3.4).</p>
  
  <p>Can anyone point me in the direction as to what is going wrong please?</p>
  
  <p>Thank you</p>