Doctrine2 - No Metadata Classes to process

前端 未结 9 2047
清歌不尽
清歌不尽 2020-12-13 06:15

Something is wrong with documentation or me. I do all what documentation says.

When i put in terminal :

$ php vendor/bin/doctrine orm:schema-tool:c         


        
相关标签:
9条回答
  • 2020-12-13 06:44

    I had the same problem when creating a new doctrine config in a new ZF2 module.

    problem was caused by

    'User\Entity' => 'property_entities'

    the user part was from the old entity

    'Property\Entity' => 'property_entities'

    Changing that fixed the issue

    0 讨论(0)
  • 2020-12-13 06:45

    I think you took the config example from Doctrine2: getting started:

    $isDevMode = true;
    $config = Setup::createAnnotationMetadataConfiguration([__DIR__."/src"], $isDevMode);
    

    The trick is now that the Setup::createAnnotationMetadataConfiguration method uses a SimpleAnnotationReader by default. You can change this behaviour by changing the fifth parameter to false:

    $isDevMode = true;
    $config = Setup::createAnnotationMetadataConfiguration([__DIR__."/src"], $isDevMode, null, null, false);
    

    This will force Doctrine to use the not-simple AnnotationReader which can handle your models now!

    0 讨论(0)
  • 2020-12-13 06:45

    Try clearing the cache:

    sudo -u www-data php app/console cache:clear --env=dev
    
    0 讨论(0)
  • 2020-12-13 06:47

    Had the same issue with custom Doctrine installation. My solution was to re-set metadata driver:

    $config->setMetadataDriverImpl(
        new Doctrine\ORM\Mapping\Driver\AnnotationDriver(
            new Doctrine\Common\Annotations\CachedReader(
                new Doctrine\Common\Annotations\AnnotationReader(),
                new Doctrine\Common\Cache\ArrayCache()
            ),
            ENTITY_DIR
        )
    );
    

    Solution from http://support.skipper18.com/1120/how-use-external-tools-generate-doctrine-getters-and-setters?show=1121#a1121 My scenario was generating entities from existing database

    The newDefaultAnnotationDriver adds the namespace and the method comments state the following:

    If $useSimpleAnnotationReader is true, the notation @Entity will work, otherwise, the notation @ORM\Entity will be supported.

    0 讨论(0)
  • 2020-12-13 06:48

    In my case, the issue was with the number of asterisk used for the annotation

    <?php
    
        namespace Models;
    
        use Doctrine\ORM\Annotation\{Id, Column, GeneratedValue, Entity};
    
        /** // I originally used one asterisk here and kept getting the error in question. Error disappeared after doubling the asterisk as it is in this answer
        * @Entity(repositoryClass="Doctrine\ORM\Annotation\Id")
        */
       class User {
       }
    
    ?>
    
    0 讨论(0)
  • 2020-12-13 06:52

    Uncomment the one of the following lines in bootstrap.php:

    // or if you prefer yaml or XML
    //$config = Setup::createXMLMetadataConfiguration(array(__DIR__."/config/xml"), $isDevMode);
    //$config = Setup::createYAMLMetadataConfiguration(array(__DIR__."/config/yaml"), $isDevMode);
    

    Which depends if you created yaml or xml meta config files...

    Hope this helps.

    0 讨论(0)
提交回复
热议问题