3

We have a monorepo that includes our old monolith as well as our new modules. (We don't want separate repos...yet)

src/Monolith/...
src/OrderModule/...
src/PaymentModule/...

We obviously don't want our new modules coupled to the monolith. We also don't want certain modules depending on other modules. eg: the OrderModule can depend on the PaymentModule, but not the other way around.

Is there a phpcs or linter rule for preventing "innapropriate" cohesion? Something that restricts imports would work.

JavaScript's ESLint has no-restricted-imports, no-restricted-modules and nx-enforce-module-boundaries which will enforce custom boundary rules. Is there a PHP equivalent?

Bonus: We're using DDD hexagonal architecture, so we could even use these rules to enforce separation between the application, domain and infrastructure layers!

Matt Janssen
  • 1,505
  • 13
  • 14

0 Answers0