Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><strong>EDIT 3:</strong></p> <p>If it matters, I'm using Doctrine 2.2.1. Anyway, I'm just adding a bit more information on this topic.</p> <p>I dug around the Doctrine\Configuration.php class to see how newDefaultAnnotationDriver created the AnnotationDriver. The method begins on line 125, but the relevant part is line 145 to 147 if you're using the latest version of the Common library.</p> <pre><code>} else { $reader = new AnnotationReader(); $reader-&gt;setDefaultAnnotationNamespace('Doctrine\ORM\Mapping\\'); } </code></pre> <p>I couldn't actually find the setDefaultAnnotationNamespace method in AnnotationReader class. So that was weird. But I'm assuming it sets the namespace Doctrine\Orm\Mapping, so that annotations in that namespace don't need to be prefixed. Hence the error since it seems the doctrine cli tool generates the entities differently. I'm not sure why that is.</p> <p>You'll notice in my answer below, I didn't call the setDefaultAnnotationNamespace method.</p> <p>One a side note, I noticed in your User Entity class that you have <code>use Doctrine\Mapping as ORM</code>. Shouldn't the generated file create <code>use Doctrine\Orm\Mapping as ORM;</code>? Or maybe that is a typo.</p> <p><strong>EDIT 1:</strong> Ok, I found the problem. Apparently it has to do with the default annotation driver used by the \Doctrine\ORM\Configuration class. </p> <p>So instead of using <code>$config-&gt;newDefaultAnnotationDriver(...)</code>, you need to instantiate a new AnnotationReader, a new AnnotationDriver, and then set it in your Configuration class.</p> <p>Example:</p> <pre><code>AnnotationRegistry::registerFile("Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php"); $reader = new AnnotationReader(); $driverImpl = new \Doctrine\ORM\Mapping\Driver\AnnotationDriver($reader, array(__DIR__ . "/application/persistent/Entities")); $config-&gt;setMetadataDriverImpl($driverImpl); </code></pre> <p><strong>EDIT2</strong> (Here the adjustments added to your cli-config.php):</p> <pre><code>use Doctrine\Common\Annotations\AnnotationReader; use Doctrine\Common\Annotations\AnnotationRegistry; require_once 'Doctrine/Common/ClassLoader.php'; define('APPLICATION_ENV', "development"); error_reporting(E_ALL); $classLoader = new \Doctrine\Common\ClassLoader('Doctrine'); $classLoader-&gt;register(); $classLoader = new \Doctrine\Common\ClassLoader('Entities', __DIR__ . '/application/'); $classLoader-&gt;register(); $classLoader = new \Doctrine\Common\ClassLoader('Proxies', __DIR__ . '/application/persistent'); $classLoader-&gt;register(); $config = new \Doctrine\ORM\Configuration(); $config-&gt;setProxyDir(__DIR__ . '/application/persistent/Proxies'); $config-&gt;setProxyNamespace('Proxies'); $config-&gt;setAutoGenerateProxyClasses((APPLICATION_ENV == "development")); //Here is the part that needs to be adjusted to make allow the ORM namespace in the annotation be recognized #$driverImpl = $config-&gt;newDefaultAnnotationDriver(array(__DIR__ . "/application/persistent/Entities")); AnnotationRegistry::registerFile("Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php"); $reader = new AnnotationReader(); $driverImpl = new \Doctrine\ORM\Mapping\Driver\AnnotationDriver($reader, array(__DIR__ . "/application/persistent/Entities")); $config-&gt;setMetadataDriverImpl($driverImpl); //End of Changes if (APPLICATION_ENV == "development") { $cache = new \Doctrine\Common\Cache\ArrayCache(); } else { $cache = new \Doctrine\Common\Cache\ApcCache(); } $config-&gt;setMetadataCacheImpl($cache); $config-&gt;setQueryCacheImpl($cache); $connectionOptions = array( 'driver' =&gt; 'pdo_mysql', 'host' =&gt; '127.0.0.1', 'dbname' =&gt; 'mydb', 'user' =&gt; 'root', 'password' =&gt; '' ); $em = \Doctrine\ORM\EntityManager::create($connectionOptions, $config); $platform = $em-&gt;getConnection()-&gt;getDatabasePlatform(); $platform-&gt;registerDoctrineTypeMapping('enum', 'string'); $helperSet = new \Symfony\Component\Console\Helper\HelperSet(array( 'db' =&gt; new \Doctrine\DBAL\Tools\Console\Helper\ConnectionHelper($em-&gt;getConnection()), 'em' =&gt; new \Doctrine\ORM\Tools\Console\Helper\EntityManagerHelper($em) )); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload