4

Ok I have one last problem with doctrine:generate:entities command

I run the below command and I get the expected file(s) in

/src/MyNamespace/Bundle/MyNamespaceBundle/Resources/config/doctrine/metadata/orm

comamnd:

php app/console doctrine:mapping:convert yml ./src/MyNamespace/Bundle/MyNamespaceBundle/Resources/config/doctrine/metadata/orm --from-database --em=my_manager --filter=TblReports --verbose

I see the TblReports.orm.yml file(s) and the first line is:

TblReports

command: ( should this be annotation instead of yml? )

php app/console doctrine:mapping:import MyNamespaceBundle yml --em=my_manager --filter=TblReports

I run the above command I get the files here

/src/MyNamespace/Bundle/MyNamespaceBundle/Resources/config/doctrine/

Same name as the first files that were generated from the first command, just in a different location and the first line ( Which I'm assuming is the namespace )

TblReports.orm.yml

and now the first line is:

MyNamespace\Bundle\MyNamespaceBundle\Entity\TblReports

but I think it needs to be

MyNamespace\Bundle\MyNamespaceBundle\Entity\Reports\TblReports

Now I run the last command

php app/console doctrine:generate:entities MyNamespaceBundle --path=src --no-backup

I get this error

[RuntimeException]                                                    
  Bundle "MyNamespaceBundle" does not contain any mapped entities.

If I run the command like this

php app/console doctrine:generate:entities MyNamespaceBundle:Reports --path=src --no-backup

I get this error ( but the namespace looks correct )

  [RuntimeException]                                                                                   
  Namespace "MyNamespace\Bundle\MyNamespaceBundle\Entity\Reports" does not contain any mapped entities. 

Here is my_manager ( config.yml )

# Doctrine Configuration
doctrine:
    dbal:
      default_connection: my_database
      connections:
        my_database:
          driver:   pdo_pgsql
          port:     5432
          dbname:   tbl_reports
          user:     foo_user
          password: foo_pass
          charset:  UTF8
          mapping_types:
            bit: string

    orm:
        auto_generate_proxy_classes: "%kernel.debug%"
        default_entity_manager: my_manager
        entity_managers:
            my_manager:
                connection: my_database
                mappings:
                    MyNamespaceBundle:
                      mapping: true
                      dir: Entity/Reports

in config_dev.yml ( I use the dev and prod yml files to control the host(s) I can connect to )

# Doctrine Configuration
doctrine:
    dbal:
      connections:
        my_database:
          host: 172.0.0.1

Questions:

  1. Why am I getting this error?
  2. How can I fix it?

Related Questions:

UPDATE #1:

Ok well I ran the second command as annotation instead of yml and the files were generated in:

MyNamespace\Bundle\MyNamespaceBundle\Entity

command:

php app/console doctrine:mapping:import MyNamespaceBundle annotation --em=my_manager --filter=TblReports

I ran the doctrine:generate:entities ( both ways ) and still got errors. I decided to move the files into this directory

MyNamespace\Bundle\MyNamespaceBundle\Entity\Reports

I ran the doctrine:generate:entities agin ( both ways ) and still got errors. I looked at the namespace in the files and saw it was pointing to the work namespace. I updated from:

MyNamespace\Bundle\MyNamespaceBundle\Entity\TblReports

to

MyNamespace\Bundle\MyNamespaceBundle\Entity\Reports\TblReports

ran this command

php app/console doctrine:generate:entities MyNamespaceBundle:Reports --path=src --no-backup

and in now works

Generating entities for namespace "MyNamespace\Bundle\MyNamespaceBundle\Entity\Reports"

So I guess question #3 is:

  1. How can I get the second command to add the correct namespace on the import?

I tried this but no dice

php app/console doctrine:mapping:import MyNamespaceBundle:Reports annotation --em=my_manager --filter=TblReports

Docs:

Source:

Community
  • 1
  • 1
Phill Pafford
  • 83,471
  • 91
  • 263
  • 383

1 Answers1

0

Your first line needs to end with a : as in:

MyNamespace\Bundle\MyNamespaceBundle\Entity\TblReports: 
  <yml> data.

You seem to be mixing annotations with yml. Pick one and stick with it. I don't use annotations, so the rest is yml comments. doctrine:mapping:import/convert with yml option generates yml files puts the yml files in Bundle/Resources/config/doctrine.

The collection of yml files are then used to make your entity classes, and it will put them in the location specified in each yml file, which be default is NamespaceBundle\Entity.

Lighthart
  • 3,648
  • 6
  • 28
  • 47
  • Thanks, I get that part. How do I change that namespace? From NamespaceBundle\Entity to NamespaceBundle\Another\Namespace\Entity – Phill Pafford Dec 08 '12 at 01:37
  • Put the doctrine files into the directory associated with that namespace, and generate them there? – Lighthart Dec 08 '12 at 02:07
  • Could you list all three commands? I'm trying your suggestion but all I get are errors. Does the order matter? – Phill Pafford Dec 10 '12 at 14:11
  • doctrine:mapping:import Bundle yml php app/console doctrine:generate:entities MyNamespaceBundle --path=src But you've done these. My understanding is that symfony's model is to put your reporting entities in their own bundle, and hence the Entity\Reports directory will cause you trouble – Lighthart Dec 10 '12 at 16:56