What is the difference between a controller and a service?

I am looking for how to structure my application layer between the presentation layer and the model / business object layer. I see examples using the Controller classes and others using the Service classes. Are these the same things with different names for different methodologies, or is there a more fundamental difference?

Edit: To put the question in context, this is a PHP application using Doctrine as an ORM.

+6
oop architecture
source share
1 answer

I would say that terms like Controller are basically the same name for potentially very different things depending on which methodology / structure you use. At a very high level, they can perform the same action - hence, using a common name - but their responsibilities and scope in the context of the structure will usually be much more specific and different.

For example: The controller in MVC has little or nothing to do with the WCSF controller level.

I think that these terms, such as Controller / Service, etc., are universal and, therefore, are used in many frameworks, but they have special meaning within the framework of the link.

In addition, in particular, the controller and the service for me are two completely different concepts.

A controller is something like a layer that is responsible for organizing the logic in the application / or aspect of the application.

A service, for me, is basically an external API through which you expose aspects of your application in a standard way.

+2
source share

All Articles