Modular architecture with hooks for apps

G’day all!

When I write web apps in Yii2 I find that I have a lot of reusable components. I always have authentication, acl’s, logging, menu builders, system properties, etc. I am looking to hear what you all do to manage your code if you work the same way.

I am thinking of either doing one of the following:

  1. Create a ‘base application’, with lots of modules (one for each app) and use hooks/events to register menu items, etc. This would result in 1 code base for all my apps.

  2. Create a base application which I extend and create a copy of it for each project I work on. This would provide more flexibility but multiple code bases to manage.

When I think about it, what I want to build is no different to the modules that I download from Github. But I guess my concern is that I want to integrate the modules a lot closer into the base code (ie. I have a notification tab, and a consistent way for creating menus).

Are there any design patterns or system architectures around for how I may build this type of modular application? Would it all be driven by modules & events?

Cheers

Dan

I’m extracting these into OpenSource components where possible such as https://github.com/samdark/sitemap or https://github.com/samdark/yii2-iconized-menu-widget. When extracted well, it’s easy to reuse these. If most of the projects you’re working on are similar, I suggest creating your own application templates (it’s described in the guide).