search

Home  >  Q&A  >  body text

symfony - Use commands to generate different corresponding entities in different bundles according to the database in a project

In a project, use commands to generate different corresponding entities under different bundles according to the database. database: test table: account,product

There are two bundles in the symfony project

DemoAccountBundle DemoProductBUndle

Use the command directly without considering the corresponding relationship. php app/console doctrine:mapping:import DemoAccountBundle yml
You can generate everything but it will be under DemoAccountBundle
Is there a way to select generated entities?
The structure is as follows
DemoAccountBundle Entity:Account.php
DemoProductBundle Entity:Product.php

Continuing research, if anyone has implemented it, please let us know.

世界只因有你世界只因有你2826 days ago446

reply all(1)I'll reply

  • 滿天的星座

    滿天的星座2017-05-16 16:47:06

    You've do this way,

    php app/console doctrine:mapping:convert whateveryouwant ./src/App/MyBundle/Resources/config/doctrine --from-database --filter="Yourtablename"
    Then
    php app/console doctrine:mapping:import AppMyBundle whateveryouwant --filter="Yourtablename"
    And finall
    php app/console doctrine:generate:entities AppMyBundle --no-backup
    Like this doctrine will load only the entity you need. Just be carefull on the filter you must use the CamelCase.

    reply
    0
  • Cancelreply