Whatever you do keep the Domain layer pure, without any dependencies to other layers.
In Application Bundle, I have application, domain and infrastructure (tiers?), where application has the public API (presentation layer).
The Application layer is not the Presentation layer.
The Application layer
exposes the use cases of your domain. It's a thin layer, with no business rules. In general there is only one layer of this type. In this layer you most probable have Application services (classes) that basically do this: load an Aggregate
root from the Repository
, calls a method on it and then it persists the changes to the Repository
. Of course, it may have other responsibilities like authorization: for example here you check that if the user is an admin
it can delete any Product
.
The Presentation layer
is the client of the Application layer
. There could be more than one Presentation layer
that uses the Application layer
. The main responsibility of this layer is to gather the input from the user and call Application services
- services that live in the Application layer
. One other responsibility is to display the data to the user. Examples of Presentation layers
: A MVC presentation layer, a REST endpoint.
Since I will have application, domain and infrastructure services, I thought about making an application service for each domain service I need
You should create an application service for each use case, not for every domain service. One note about domain services: be aware of the anemic domain model.
About the types of use of the Application layer: if you host the Presentation layer
and the Application layer
on the same server, for example if you have a MCV
on top of the Application layer
, then you can call the Application services
directly from your Controller
, like normal method calls. If you separate the frontend from the backend then you cannot call the application services directly but you can use a REST
endpoint on top of the Application layer
.
Now, I need to access an API from the WebUiBundle, but not the public API for first-rendering, I want to make it internal.
Application layer
is always internal. It needs a Presentation layer
to make it accessible.