Yii is by far considered as the best framework within PHP fraternity. A framework that can be used to develop any kind of web-application, Yii, is specially the best for being fast and flexible. This macro PHP framework comprises of great design, has a lot of functionalities, is easy to extent and easy to configure.

The release of Yii 2.0 beta has triggered a wave of excitement with its new features, functions, changes and bug fixes. Yii2.0, currently being in public preview is not suggested by experts to use in any kind of projects. It supports PHP 5.3 and only some of the functionalities have been imported from Yii 1.1. The new version is publicized as much improved and comprehensive framework.

Let’s take a look at some of the new interesting features of Yii 2.0:

NAMESPACE

In the current stable version the core classes are not name spaced and to avoid any confusion the names use “C” prefix viz. \CGridview, \CDataColumn is used. The classes have to be in global namespaces. In Yii 2.0 the namespace organization is better than the stable version. The names no longer use ‘C’ prefix and all the core classes are now name spaced, avoiding the uncertainty in class names. Namespaces are now based on directory structure viz. yii\web\request, yii\web\application

COMPONENTS AND OBJECTS

The component class is now segregated into two further classes—Object class and Component class. The object class contains the basic data structures while component class is used to implement higher logic with events and behaviors.

OBJECT CONFIGURATION

OBJECT-CONFIGURATION

In Yii 2.0 the Object configuration in the upcoming version is simplified by using uniform way of configuring objects. A constructor must be declared by any descendent class of OBJECT.

new-features-in-Yii-2.0

EVENT HANDLER

In Yii 2.0 version, any name can be used for the event with attached handler to it. Event is more straightforward using J-query like event handle and on-event method definition is no longer needed.

event-handler

VIEW

In Yii 2.0 a new ‘view’ class is used to represent the view part of MVC pattern. The ‘view’ class can be configured worldwide and is available in any view file via $this, which refers to the view object and no to the controller. Prado support is removed from the upcoming version. While it continues to use PHP as the main language, two extensions, Smarty and Twig support are added. Also, in the current version there is no more CClientScript. Controller and widgets are now accesses as View’s context.

New features in Yii 2.0

MODEL

Yii 2.0 uses a formname() method that returns the previously hardcoded form name. This is used to collect user inputs for a model. To define which fields need to be validated or to declare what attributes need validation, a new method known as scenarios() is introduced. This makes Yii 2.0 a safe validator.

WIDGETS

In Yii 2.0 the usage of widget is very much uncomplicated, where begin(), end() and widget() methods are used. This has improved the IDE support.

New features in Yii 2.0

ACTIVE RECORD

In Yii 2.0 the major changes are seen in active record. Relational Active Record query is now done through getter method, which returns ActiveQuery that extends query.

 active-record-in-yii-2.0

THEME

In Yii 2.0 works in a totally different manner. Translation of source view into theme view is done through a ’path map’ now. All the view files can now have a theme even if they are present outside the context of controller.

These were some of the major changes that are expected in the new version as of now. These changes to Yii 1.1 have triggered more enthusiasm among the developers. According to the experts, all the best functionalities and best practices are adapted in the upcoming version of Yii framework, which is sure to take PHP Web Development to another level.

For more information you can REACH OUT TO US HERE.

Stay Tuned for Latest Updates

Fill out the form to subscribe to our newsletter

Partner with our experienced development team.

Contact Us
Contact Us
Loader