I have been searching on google for this and am not able to find the answer. I’m new to Symfony. In some places I hear about schema.yml and you can create all the tables with it. But in Symfony2, exactly where do we create that file? The following page: http://symfony.com/doc/2.0/book/doctrine.html, really doesn’t answer that question and its from the Symfony page..
Is there any documentation that can answer this question? For Symfony1.x I hear that you can create a schema.yml file and then run a create shema command to create all the tables etc. Right now i’m able to create the database, but how can I create the tables? Where do I define them in Symfony2?
In Symfony2, you need to define the mapping entity by entity. There is three different kind of mapping: Annotation, YAML and XML mapping.
The Symfony page you are linking does answer the question to this question. For example, if you got to the Mapping section, you will see this paragraph:
Then, if you go just a bit below, you see a tabbed pane with the three mapping options. Click on the YAML tab and you will see:
This piece of YAML is the mapping informations and is located at this location:
src/Acme/StoreBundle/Resources/config/doctrine/EntityName.orm.yml. TheEntityNamepart should be changed with the name of your own entity. If you entity class is Product, the it will beProduct.orm.yml. You will need to define multiple.ymlfiles to define mutliple entities.The next step is to populate the database schema. Assuming your configuration is good, you will use these commands to respectively drop and create the database:
Then, to populate the schema, you must use this command:
The documentation for Doctrine is the place to check for other mapping informations and all the stuff you need for database interaction in Symfony2 via Doctrine.
Regards,
Matt