Javatpoint Logo
Javatpoint Logo

Upgradation of Yii1.1 to Yii2

There are many differences between 1.1 and 2.0 version of Yii. It was completely rewritten for version 2.0. There are some major differences between both the versions. Yii2 has introduced some more new features.


Changes regarding PHP

There are many differences in the PHP language used for Yii1.1 and Yii2. Some major changes are listed below.

  • PHP 5.4+
  • Namespaces
  • Anonymous functions
  • Short array syntax is used instead of full syntax
  • In view files, short echo tags <?= are used.
  • Standard PHP library and interfaces
  • Uses Late Static Binding feature.
  • Uses a method of code reuse called Traits.

Namespace

The most important change in Yii2 is the use of namespace. Every class name is namespaced. This naming scheme follows the directory structure means it indicates the location of the corresponding file.


Events

In Yii1, events were defined by an on- method. In Yii2, you can just call trigger() function to use any event name.


Views

The most important change in views is that $this now no longer refers to current controller. Instead, it refers to a view object. To access a controller in the view part use $this->context.


Assets

Yii2 introduces a new concept called asset bundle. An asset bundle is a collection of asset files within a directory. Assets in the bundle are made accessible via Web.

Next TopicYii2 Installation




Please Share

facebook twitter google plus pinterest

Learn Latest Tutorials


Preparation


B.Tech / MCA