Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can Symfony2 generate:doctrine:entity generate entity with one-to-many relationship?

I suppose the answer is no but I am asking to be sure. SensioGeneratorBundle contains a command to generate entities. Do you know if it can generate the mappings for a one2Many or Many2Many field? Is there any project that implements this?

The only example I found:

 php app/console doctrine:generate:entity --entity=AcmeBlogBundle:Blog/Post --format=annotation --fields="title:string(255) body:text" --with-repository --no-interaction

Many thanks

like image 722
Tiago A. Avatar asked Jan 08 '14 19:01

Tiago A.


3 Answers

There is a workaround that makes the job perfectly, without any additional software or bundle to install.

You just have to edit the DatabaseDriver.php from doctrine like described here :

Symfony2 Doctrine2 - generate One-To-Many annotation from existing database by doctrine:mapping:import

like image 83
b126 Avatar answered Nov 16 '22 16:11

b126


I know this is old... but this could help some people.

Here is a Symfony3 bundle that can generate Doctrine 2 associations, including a one-to-many relationship:

https://github.com/Remg/GeneratorBundle

Associations

  • Handles all Doctrine2 association types (OneToOne, OneToMany, ManyToOne, ManyToMany).
  • Handles unidirectional and bidirectional associations.
like image 26
Remg Avatar answered Nov 16 '22 16:11

Remg


AFAIK the answer is no. I have already asked a similar question and it seems that there is no free tool that can do that. But if you want to pay : http://www.orm-designer.com/

like image 26
2 revs Avatar answered Nov 16 '22 16:11

2 revs