Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7593997
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T21:18:36+00:00 2026-05-30T21:18:36+00:00

I have been searching on google for this and am not able to find

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T21:18:37+00:00Added an answer on May 30, 2026 at 9:18 pm

    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:

    For Doctrine to be able to do this, you just have to create “metadata”, or configuration that tells Doctrine exactly how the Product class and its properties should be mapped to the database. This metadata can be specified in a number of different formats including YAML, XML or directly inside the Product class via annotations:

    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:

    # src/Acme/StoreBundle/Resources/config/doctrine/Product.orm.yml
    Acme\StoreBundle\Entity\Product:
        type: entity
        table: product
        id:
            id:
                type: integer
                generator: { strategy: AUTO }
        fields:
            name:
                type: string
                length: 100
            price:
                type: decimal
                scale: 2
            description:
                type: text
    

    This piece of YAML is the mapping informations and is located at this location: src/Acme/StoreBundle/Resources/config/doctrine/EntityName.orm.yml. The EntityName part should be changed with the name of your own entity. If you entity class is Product, the it will be Product.orm.yml. You will need to define multiple .yml files 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:

    php console doctrine:database:drop --force
    php console doctrine:database:create
    

    Then, to populate the schema, you must use this command:

    php console doctrine:schema:update --force
    

    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

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been searching but have not been able to find this out. Essentially, when
I have been searching around using Google but I can't find an answer to
I hope I am not repeating anyone here, but I have been searching google
Ok, so I have been searching for quite some time on this. I have
After performing some Google-fu and searching Stack Overflow I've been unable to find a
I have been searching for this on Google for a while and maybe I'm
I have done a lot of searching about this topic through Google but I
I have been searching on SO and google all this afternoon to try and
I have been searching google for over an hour and am frustrated, This seems
I have been searching for a solution to this and so far found nothing

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.