Reputation: 2481
In Yii PHP framework, one has ability to create modules. As per Yii's official documentation here is definition of the module:
A module is a self-contained software unit that consists of models, views, controllers and other supporting components. In many aspects, a module is similar to an application. The main difference is that a module cannot be deployed alone and it must reside inside of an application. Users can access the controllers in a module like they do with normal application controllers.
Let's say we have a huge aplication and we have to create front-end and backend. In this case, is it better to create frontend module
, and backend module
and use them, or it is better to implment frontend as one Yii application, and backend as second Yii application.
I'm asking this because if you look at Yii's 2 advance template, there three are different applications (common, backend, frontend
), but they are not implemented as three different modules, and my question is why?
Is app is going to be slower when you use modules and what are pros and cons of using modules?
Upvotes: 2
Views: 792
Reputation: 9367
Yii2 advance template has 3 different applications however they are frontend, backend and console (not common).
is it better to create frontend module, and backend module and use them?
The answer is "it depends". Lets take some examples:
The answer to use or not to use modules is actually the same answer to "Will I use this in other applications and can it function without the rest of the application?" A module should NOT be tight coupled with the rest of the application.
Upvotes: 3
Reputation: 41
The idea of the modules in that they almost autonomous. At the stage of application development you must highlight from it all stand-alone elements. For example, I have a large CRM. I need a user module (includes all models associated with the user, controllers, display components and their configuration - for example the rules of routes). There is also an administrative module. There CRM module and a module for corporate events and meetings schedules. And about 3-5 independent modules - for example internal communications module,access control module and module of electronic payments. The convenience is that the all modules are self-contained. They have their own MVC- sets, sets of widgets and configurations. And they can be moved from one project to another without much effort.
Here's another interesting modular system: There are resource with various functionality. It can be divided into modules. Each module file should implement a modular interface (you need to write it). For example, I want each module to provide its own widget for menu.(Drop-down list or just a button) and its own widget for dashboard. Also in the module file specified access to various actions, etc.
There is a basic component,that prior to the step of rendering polls all modules at their regulated functionality and builds on its basis the menu, dashboard and other widgets. The main thing with this approach, keep in mind, that everything that module provides must be prepared by the modular functionality(models, widgets) not to disrupt the modular autonomy.
Upvotes: 0