Doctrine2 - No Metadata Classes to process

前端 未结 9 2048
清歌不尽
清歌不尽 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:59

    Try the following command:

    php vendor/bin/doctrine-module orm:schema-tool:create
    
    0 讨论(0)
  • 2020-12-13 07:06

    If you're using the XML mapping (using Setup::createXMLMetadataConfiguration()), you might want to pay attention to the following:

    • That your XML mapping files ends by .dcm.xml, not only by .xml.
    • That your XML file contains the full entity classname, inclusive of the namespace. For example, for a class Company\Solution\Models\User, you must have the Company.Solution.Models.User.dcm.xml mapping file in your XML path.
    0 讨论(0)
  • 2020-12-13 07:07

    TL;DR: Make sure the type of metadata you created matches the "create metadata configuration" method you used.

    I encountered the same problem while working through the Doctrine "Getting Started" guide. After looking through the Doctrine code a bit I figured out what was going wrong. Basically, the code in the tutorial in the "Obtaining the EntityManager" section is:

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

    A little further in the tutorial, in the "Starting with the Product" section, it shows us how to set up the metadata, with an example for each of the possible options for this. The tutorial says:

    Metadata for entities are configured using a XML, YAML or Docblock Annotations. This Getting Started Guide will show the mappings for all Mapping Drivers. References in the text will be made to the XML mapping.

    Because of this statement, I decided to use the XML configuration. Unfortunately, the createAnnotationMetadataConfiguration method in the tutorial code did not seem to be using the XML file I had created. (In hindsight, it seems much more obvious that this method is specifically referring to annotation metadata, not XML metadata!)

    After I changed it to createXMLMetadataConfiguration instead, it worked as expected. So it looks like one possible source of this problem is that the "create metadata configuration" method you used may not match the type of metadata you created.

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