yii2 - How to properly use Yii modules? -


in yii php framework, 1 has ability create modules. per yii's official documentation here definition of module:

a module self-contained software unit consists of models, views, controllers , other supporting components. in many aspects, module similar application. main difference module cannot deployed alone , must reside inside of application. users can access controllers in module normal application controllers.

let's have huge aplication , have create front-end , backend. in case, better create frontend module, , backend module , use them, or better implment frontend 1 yii application, , backend second yii application.

i'm asking because if @ yii's 2 advance template, there 3 different applications (common, backend, frontend), not implemented 3 different modules, , question why?

is app going slower when use modules , pros , cons of using modules?

yii2 advance template has 3 different applications frontend, backend , console (not common).

is better create frontend module, , backend module , use them?

the answer "it depends". lets take examples:

  1. i have "users" section in backend tells system can each user change in backend. use in multiple applications no change @ have created user module can insert wherever want. simplest module because never use frontend.
  2. a blog module, blog module little more complicated has place manage blog (this part in backend) , posts , comments shown in front section (this part should in frontend). still want able plug in multiple applications. solution create folders in actual module (i created same structure frontend / backend / common). logic same, in website frontend use find in frontend folder of module, common holds things use in both frontend , backend (like models) etc. different application use same frontend controllers / widgets make sure allow views changed.

the answer use or not use modules same answer "will use in other applications , can function without rest of application?" module should not tight coupled rest of application.


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -