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:
- Why am I getting this error?
- 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:
- 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: