質問

Now, im facing three issues about my symfony 2 application architecture using Doctrine 2. This is a one bundle application.

  1. I will use some controllers of course, but I need some special controller "BeforeController" to be called before the others. In the "BeforeController" I want to place some initialize methods. Is it best practice to extends controllers by "BeforeController"?

  2. I want to create some services in ServiceContainer. For every entity which I have, I want to create own service (e.g. There is Products entity, so I will create Product service, which provides methods manipulating with products and so on), if is it good way. Or is it in Controller compentence?

  3. Can somebody explain me, what is in controller or in service competence?

I should like to create some logical and intuitive architecture. Maybe any class diagram should help me.

Can somebody describe me some best practices about it?

役に立ちましたか?

解決

From documentation:

  1. kernel.controller Event, and example: Before filters with the kernel.controller Event,
  2. Service: Service base info and more: What is a Service? Controller base info, and additionally Action. It's nothing wrong with creating separate services for each entity if you really need it.
  3. As above.

I recommended this video from SymfonyCon Warsaw 2013 How Kris Writes Symfony Apps.

Hope this help.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top