Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When to use components and when to use extensions in Yii?

Tags:

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

Please clarify.

like image 263
oaziz Avatar asked Dec 08 '11 04:12

oaziz


People also ask

What are Yii components?

Yii applications are built upon components which are objects written to a specification. A component is an instance of CComponent or its derived class. Using a component mainly involves accessing its properties and raising/handling its events. The base class CComponent specifies how to define properties and events.

What is Yii Best for?

Yii is the first choice of the developers over the other PHP frameworks because of its developer-friendly features. Its features are secure, reliable, and easy to configure. It is ideal for websites and web apps that are having high traffic for example web portals, eCommerce portals, or CMS Websites.

Why Yii is the best framework?

The Benefits of Yii2 Development Like Symphony and Laravel, Yii2 is an open-source framework for both back-end and front-end programming. A lot of explanatory documentation helps to sort out many issues and the framework is also supported by a community of significant size. Yii also supports Object-Relational Mapping.

What is $App in Yii?

Applications are objects that govern the overall structure and lifecycle of Yii application systems. Each Yii application system contains a single application object which is created in the entry script and is globally accessible through the expression \Yii::$app .


1 Answers

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.

like image 184
Arfeen Avatar answered Nov 02 '22 10:11

Arfeen