Magento 2 follows MVVM architecture or MVC architechure?
-
07-02-2021 - |
Question
I am understanding the logic behind working in separate folders in Magento 2 and came across bundle of articles talking about same thing in different ways.
Some explain MVC logic behind it and some say it is MVVM
Meanwhile Official Website says to follow MVC architecture in extension development.
If we are following MVVM (or any other) architecture can somebody explain it by relating it with Magento 2 directory structure.
Thanks.
La solution
Magento 2 has its own unique implementation; MVC, MVVM or HMVC, none of them are specifically followed. When you create a new module, you are following MVC or HMVC, on the frontend and especially on checkout MVVM is implemented with the strong blend of KnockoutJS and on admin side it is HMVC.
After all this, I will repeat, Magento 2 has its own implementation unique to Magento 2 and none of them are specifically followed.
There are rumors going around about KnockoutJS, it might be dropped from future releases of Magento (I am not sure though).
Autres conseils
Magento 2 is a Model View ViewModel System and no more a design structured by MVC. The MVC model was incorporated in the previous version and seems to be quite similar to MVVM, but MVVM is a way more rich in dividing the View and Model in an application. Reference: https://weblizar.com/blog/magento-2-is-model-view-view-model-system-and-not-mvc-explained/
Magento 2 — No More MVC, it’s closer to a Model, View, ViewModel (MVVM) system.
What is MVVM Syste?
https://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93viewmodel
Magento 2 is a Model View ViewModel (MVVM) system. While being closely related to its sibling Model View Controller (MVC), an MVVM architecture provides a more robust separation between the Model and the View layers.
https://www.toptal.com/magento/magento-2-tutorial-building-a-complete-module
https://www.yireo.com/blog/2017-08-12-viewmodels-in-magento-2