A
A
andry_vv2019-02-11 11:59:06
symfony
andry_vv, 2019-02-11 11:59:06

Application layers in Symfony?

Hello
As practice shows, if you write in Symfony based on the documentation, the framework "pushes" the user to use application layers with their own area of ​​responsibility. For example, communication with the database goes through the repository, business logic is most often described in a model, split into services. While following the documentation is a good thing, users are free to create their own layers based on their own experience or methodology.
I had a need to create the following:
- A layer responsible for atomic operations with the database (note - save(), delete(), maybe some kind of loop with little logic)
- Separation of the command into initialization, and its execution. There were ideas to separate the execution into a separate service, but what to do with the output in this case? (About the same as the handler in the Messenger component)
Have you come across such layers?
I would appreciate a detailed answer.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
F
Flying, 2019-02-11
@Flying

What is described in the paragraph about "atomic operations" is most similar to the methods in the entity repository in Doctrine.
It's not very clear about "commands", is it about a class Commandfrom symfony/command? If so, then there is a separate initialization through initialize(), it is transferred there, OutputInterfaceand if you really need it, you can call a separate service there. If you don’t want to pass the service manually to each command, you can automate it through the setter + compiler pass or through the annotation @required

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question