[Solved] How to generate Entity from yml in Symfony 2.3

0 votes
asked Jun 16, 2013 in Solved by Omegatcu (150 points)
recategorized Jun 26, 2014 by Martin Freki Stradej

Hello,

I use ORM Designer to start a new Symfony 2.3 Project and export all into yml files.
I get that i have to define the Path for the output yml file, but there is no Doctrine File generated.

Do i have to do that in Symfony 2 ? or is there an Option to let ORM Designer also export this?

1 Answer

0 votes
answered Jun 16, 2013 by ludek.vodicka Skipper developer (140,450 points)
selected Jun 26, 2014 by Martin Freki Stradej
 
Best answer

Hi,

Here is a quick step-by-step walk through how to create new project and export doctrine schema file:

1) As first, create your new project:

enter image description here

2) Edit your module settings via project tree

enter image description here

3) Choose export file and export format

enter image description here

4) Export your model to model files

enter image description here

5) Check exported file

enter image description here

Hope it helps!

commented Jun 16, 2013 by Omegatcu (150 points)

I did all of that and the yml is in the right place
(Path: #Project#/src/#NameSpace#/TestBundle/Resources/config/doctrine/Test.orm.yml)

But if i i want to generate the Class from that (doctrine:generate:entities TestBundle) doctrine says:

[Doctrine\Common\Persistence\Mapping\MappingException]
Invalid mapping file '#NameSpace#.TestBundle.Entity.Test.orm.yml' for class '#NameSpace#\TestBundle\Entity\Test'.

So is ORM Designer Providing the Entity Class or is there something wrong with my Symfony2.3 + Doctrine ?

commented Jun 16, 2013 by ludek.vodicka Skipper developer (140,450 points)

ORM Designer only exports YML/XML files so you have to be able to use Doctrine generators as same as you would write the definitions by yourself.

It's hard to say what's exactly wrong but it's possible that you have some logical error in your test model and this error is exported also to the YML files.

The best way how to find what's wrong is manually edit exported YML file and remove as much definitions as possible. Did you try to write some definition files by yourself if generator in S2+D works correctly?

commented Jun 17, 2013 by Omegatcu (150 points)

Thank you for your help on this one - my problem was that i had locally no timezone setting and so the console brought up errors.

all it needed was:
doctrine:mapping:import #BundleName# annotation

But thank you for the walk through how this works - the Tuts on the page were over a year old.

commented Jun 17, 2013 by ludek.vodicka Skipper developer (140,450 points)

You're welcome.

...