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 6611603
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T19:59:29+00:00 2026-05-25T19:59:29+00:00

In my Symfony2 project, I have a ModelBundle which holds my entities, and other

  • 0

In my Symfony2 project, I have a ModelBundle which holds my entities, and other bundles for the frontend, backend, etc, which utilise that ModelBundle.

I have a couple of model-specific functions that perform some entity-specific tasks.
Where do I put these?

  1. Do I create a seperate ‘model’ folder next to my Entity folder, and
    put all those functions in there?
  2. Do I create a controller in my ‘ModelBundle’ that holds these
    functions as actions? This might be weird, since controllers, in my
    mind, take HTTP requests and return an HTTP response, so it’s not
    applicable in this context.
  3. Do I put them inside the entity classes themselves? Is this nice?
    And is there a chance that they are over-written when I re-generate
    my ORM?
  4. Am I looking for custom repositories? I can make those and put them into a ‘model’ folder or something. http://www.doctrine-project.org/docs/orm/2.0/en/reference/working-with-objects.html#custom-repositories

P.S.: I love Symfony2, but I will be very happy when everyone has a defined set of best practices for the framework 🙂

  • 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-25T19:59:29+00:00Added an answer on May 25, 2026 at 7:59 pm

    It’d be helpful to know what type of model-specific functions you plan on writing.

    If the functionality is for an entity you’ve already fetched from the database, it belongs in the entity class.

    If the functionality has to do with finding an entity or group of entities based on specific criteria, it belongs in a custom repository class.

    I’m not a fan of thinking that model classes and entity classes should be different. IMHO, it’s an unnecessary level of abstraction.

    You’re correct in thinking that this functionality doesn’t belong in the controller.

    If you do go with custom repositories, I suggest keeping them either in an “Entity” folder, or a “Repository” folder. I personally keep mine in “Entity”, but that’s likely a side effect of having used Doctrine 1 for so long and being used to ‘Table’ classes.

    I hope this helps, but if you have any questions please post some more details of what you hope to accomplish.

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

Sidebar

Related Questions

I have a symfony2 project and I would like to create route (prefix) which
I have a PHP project (Symfony2) that uses RabbitMQ. I use its as simple
Let's say I have two entities in my Symfony2 project : Category and Article
I have a Symfony2 project which uses composer, and I'd like to use this
I have a Symfony2 project with user management (FOsUserbundle & Sonata bundles). In some
When I update my Symfony2 project I always have to do this: root@xxx:/var/www/project# php
I have a Symfony2 project with a MySQL db: #app/config/config.yml doctrine: dbal: driver: %database_driver%
I have a question about symfony2. I have a project and I am using
In symfony2 project php bin/vendors install , re-installs all bundles in deps file. Each
I have a regular class in my Symfony2 project: class RangeColumn extends Column{ //...

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.