đŸ‘‰ Go to Summary
There is no wrong or right way, there is our way.
-- Someone
.
.
.
Actions
- It represents an internal app use case.
- Each
action
must contain one use case. - Naming is important.
- An
action
can call anotheraction
orservice
in complex scenarios.
class MakeUserAvatarAction {
function __construct(){
// ...
}
function execute(){
// It does only 1 thing
}
}
Services
- It represents external integrations, commonly through API.
- You can have many methods.
class KeycloakService{
function __construct(){
// ...
}
function createUser() { }
function syncRoles() { }
...
}
Actions vs Services
- An
action
has one method, that solves one internal use case. - An
service
can have more methods, that represents an external integration.
app/
|
|__ Actions/
| |
| |__ post/
| | |
| | |__ DeletePostAction.php
| | |__ PromotePostAction.php
| |
| |__ users/
| |
| |__ MakeAvatarAction.php
|
|__ Services/
|
|__ PaymentService.php
|__ KeycloackService.php
Top comments (0)