What is the difference between component, extension & module in Yii

自闭症网瘾萝莉.ら 提交于 2019-12-20 09:22:05

问题


I am new to Yii framework, and just came across module, extension & component inside protected folder.

Can anyone please differentiate all these theoretically as well as practically also.


回答1:


Components are the classes which can help you write the business logic on the basis of your models. Suppose all of your model files are using the same logic, So that logic can be written inside component instead of writing for each controller.

Extensions are like the libraries, which basically are not dependent on your models, and hence can be reused anywhere in current or later projects. For example writing any email extension.

Module is a self-contained software unit that consists of models, views, controllers and other supporting components. In many aspects, a module resembles 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.

I hope it will help you.




回答2:


Adding my 2 cents here...

Component

your own class file you want to do something with, specific to this site only. Examples are zip compression class in an uploader app, custom encryption algo for some security app

Extension

An external class file or group of files which are re-usable, often provided by 3rd parties. Examples are facebook connect library you or someone else built, api library from ebay.com to get listing, rss reader library to read from google etc.

Module

A mini- yii based site which serves as a subset of your site,can also be reusable in other applications or is build independent to make yii even more modular. Examples are , a forum module that is independant of the site but uses only logged in user info, a user authentication module which contains integration with several sites like openid, facebook and google



来源:https://stackoverflow.com/questions/14139519/what-is-the-difference-between-component-extension-module-in-yii

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!