Yii2模块独立性

We're developing an Yii2 php appliction, which can be seen as a AirBNB clone for sake of simplicity. I'm trying to devide the application into modules, but keep getting ugly dependencies no matter how I twist or try. Couple of examples:

  • There is a booking and an item module, when displaying an item, the booking module is also to be used to disable dates when an item is already booked.
  • On the confirm booking page, a credit card form is implemented which belongs to the payment module, which couples the modules really tightly.
  • The homepage should display items, which depend on the item module for generating the right image url's etc.

How can we keep this kind of things decoupled?

For anybody looking at the same problem, I currently solved it by keeping every strictly decoupled. Modules can either make a call to a custom made WidgetRequester, which sees is a requested widget exists in another module, and returns it if it does, which solves the problem of pages with multiple module dependencies (an item page with a booking form i.e.).

Modules can also trigger normal Yii events, which can be picked up by other modules in their Bootstrap file, and process the events to their own liking.