Php 服务层应该访问多个存储库吗?

Php 服务层应该访问多个存储库吗?,php,repository,service-layer,Php,Repository,Service Layer,如果每个服务只有一个存储库,那么任何数据访问都必须经过其相应的服务业务逻辑 比如说, $userService->addUser() will call $userRepository->addUser() then send an email to the user 如果用户存储库由用户服务以外的其他服务使用。这样就有可能让另一个服务呼叫 $userRepository->addUser() directly and no email will be sent 所以为了

如果每个服务只有一个存储库,那么任何数据访问都必须经过其相应的服务业务逻辑

比如说,

$userService->addUser() will call $userRepository->addUser() 
then send an email to the user
如果用户存储库由用户服务以外的其他服务使用。这样就有可能让另一个服务呼叫

$userRepository->addUser() directly and no email will be sent
所以为了安全起见,如果另一个服务需要访问用户表,它们应该使用用户服务,而不是用户存储库。一个服务可以依赖于多个服务,但它应该只依赖于一个存储库


你的想法是什么?

我想知道为什么没有答案。这是一个好问题我早就忘记了这个问题的背景了。四年前,哇!你没有找到合理的答案吗?:)我想我放弃了php。