When to use components and when to use extensions

2019-03-14 10:07发布

I'm a little bit confused about the purpose of components and extensions folders in protected/

Please clarify.

1条回答
在下西门庆
2楼-- · 2019-03-14 10:52

According to my little experience on Yii:

Components are the classes which can help you write the business logic on the basis of your models. You definitely don't want to code all of your work in controllers, then you need the component to distribute your code and call it in 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: an email extension, or a class that send tweet to your twitter account.

It may be different for other coders/users.

查看更多
登录 后发表回答