Search code examples
symfonybusiness-logic

Where shall I put my business logic without mapping to a database in Symfony2?


I created a bundle in Symfony2 that contains my webapp. In there I have some Entities that are mapped to my MySQL-Database. They are located in Acme\MyBundle\Entities.

Now I have created some helper classes that I will not just use in MyBundle, so I outsourced them into a separate bundle (e.g. Acme\MyHelperBundle). Everything is clear until here.

But where exactly do I put business logic files? Do I put them into

  • Acme\MyHelperBundle\Entities or
  • Acme\MyHelperBundle\Resources or
  • Acme\MyHelperBundle\Resources\src
  • or any other location?

And what would be a good namespace for these helper classes?


Solution

  • create a model folder and in that make a class where you put the business logic and create a service of that class and used that classes anywhere in the project.