组件,扩展和有什么区别?Yii 中的模块 [英] What is the difference between component, extension & module in Yii

查看:24
本文介绍了组件,扩展和有什么区别?Yii 中的模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 Yii 框架的新手,刚接触到 模块扩展 &组件在受保护的文件夹内.

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.

推荐答案

组件 是可以帮助您根据模型编写业务逻辑的类.假设您的所有模型文件都使用相同的逻辑,那么该逻辑可以在组件内部编写,而不是为每个控制器编写.

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 是一个独立的软件单元,由模型、视图、控制器和其他支持组件组成.在许多方面,模块类似于应用程序.主要区别在于模块不能单独部署,它必须驻留在应用程序内部.用户可以像访问普通应用程序控制器一样访问模块中的控制器.

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.

希望能帮到你.

这篇关于组件,扩展和有什么区别?Yii 中的模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆