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

  • SEARCH
  • Home
  • 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 8574483
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T19:29:04+00:00 2026-06-11T19:29:04+00:00

I use Doctrine 2 as ORM in Symfony framework. Using annotation-based mapping for entities,

  • 0

I use Doctrine 2 as ORM in Symfony framework. Using annotation-based mapping for entities, I would have to write lot of code (setters and getters, mapping information etc.). Using YAML/XML I won’t have to write much just the column definition and metadata. In Doctrine documentation, they use mostly annotations in example with few using YAML or XML.

Should I use YAML/XML or annotations?

For annotations, I can find the documentation for every annotation at http://docs.doctrine-project.org/en/latest/reference/annotations-reference.html. I couldn’t find the equivalents of annotation in YAML or XML though; how do I convert the annotations to equivalent YAML/XML expressions?

  • 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-06-11T19:29:05+00:00Added an answer on June 11, 2026 at 7:29 pm

    This is basically down to preference.

    This is my view of things:

    Pros of annotations:

    • easier to work with, since they are close to what they describe (the properties)
    • lots of examples use them, as you have already noticed

    Pros of yaml/xml

    • this keeps the domain objects clean, so absolutely nothing from the persistence layer leaks into the domain (even if in the form of a comment)

    If you change the db or the domain, you still have to maintain them in either form, so there’s no real advantage in any direction from that standpoint.

    From a performance standpoint, in production you should be using doctrine’s caching to cache the mappings, so they are equal here too.

    Regarding this: “I would have to write lot of code, setters and getters, mapping information”:

    Doctrine requires private/protected properties, so you’ll still be writing getters and setters. And you’ll still be writing the mapping info, just in another place.

    Personally, I’d go with annotations, since it’s a lot easier to find examples and info if you need them.

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

Sidebar

Related Questions

I have the following two entities: <?php namespace Site\AnnonceBundle\Entity; use Doctrine\ORM\Mapping as ORM; use
I have Three entities: FeatureValue.php <?php namespace Webmuch\ProductBundle\Entity; use Doctrine\ORM\Mapping as ORM; /** *
I am using this in User.php use Doctrine\ORM\Mapping as ORM; use Symfony\Component\Validator\Constraints as Assert;
I have this entity: <?php namespace Comakai\MyBundle\Entity; use Doctrine\ORM\Mapping as ORM, Symfony\Component\Validator\Constraints as Assert;
Entities in symfony 2 have doctrine tags that are preceded with @ORM\ (eg @ORM\Entity).
This is my Entity: <?php namespace Trade\TradeBundle\Entity; use Doctrine\ORM\Mapping as ORM; use Symfony\Component\Validator\Constraints as
I'm working in the Symfony2 framework and wondering when would one use a Doctrine
i use two classes: namespace Test; use Doctrine\ORM\Mapping as ORM; /** *@Table() *@InheritanceType(Joined) *@DiscriminatorMap({baseclass=BaseClass,
I am developing with symfony 1.4 and using Doctrine ORM. After building schema and
What do you think, should I use ORM like Propel or Doctrine? For a

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.