Modular/Feature/Plug'n'play architecture
Hi there,
I am studying architecture options to achieve the following goal and would love to have some thoughts and different approachs.
The goal is to build a site with Core functionnalities and features/module that can be enabled/disabled. The laravel-module package look like it would bring me a lot of help regarding structure and code organization. But this do not bring solution to the code itself.
A quick example:
- Core has Auth functionnality
- A feature/module brings a Product CRUD, no interaction between the two so it is fairly easy with laravel-modules
- Then a new feature/module would bring additionnal fonctionnality to Products, like product availability on week days
Here are the solutions I've thought of:
- Using events/listeners to add functionnality during the process
- Checking module/feature enabled at some point with simple
if(is_enabled(feature_name)){
//... do stuff
}
- Same for the views, integrating components/partials if the module is enabled
- Using Macroable, seems a bit messy in the long run
The part that troubles me the more is the Models part, in my example. Core Product doesn't have days availability, this is brought by the ProductAvailability module. But I don't see much of a solution than adding it all inside the Core Product class. Using parent/child classes does not cut it as i could have another module bringing new stuff to the product later on.
Any thought/ideas on other possiblity to structure this kind of app ? I may over thinking it too, let me know :)
Thanks
Please or to participate in this conversation.