Home » , » Yii 2.0.2 – The Latest Version Released by Yii

Yii 2.0.2 – The Latest Version Released by Yii

jaki watson | 21:55 | 0 comments
Yii Framework 2.0.2
One of the best open-source web application development frameworks, Yii is based on PHP5 programming. This framework is used for simplifying application development and helps to develop robust product that you are looking for your business. Yii works great on every project type regardless of size and type.

Yii has a collection of features like Database aspect object, DB migration, MVC; Ajax based widgets and so on. Confirming the form is possible with Yii framework. The best thing is the process of authentication and authorization becomes easy with Yii. Most of the businesses are using Yii for developing social networking applications and websites.

To make this framework more attractive and advanced, the team Yii releases Yii Framework version 2.0.2 with about 40 minor new features and bug fixes. Users can found the complete list of changes in the change log.

The development progress of Yii 2 is followed by watching and starring Yii 2.0 GitHub Project. If you want to connect with other Yii developers then follow Yii Twitter feeds or join Yii Facebook group.

Check out details of some important features available in this release.

Route Alias

Earlier, aliases are supported by the core framework code that represent URLs and file paths. Now, it adds the support or route aliases. Additionally, you can develop an alias for a route and after that, use the alias to reference the route when developing a URL. The Url::to () and Url::toRoute () helper methods support Route alias. Check out example below:

use yii\helpers\Url;
Yii::setAlias('@posts', 'post/index');
// /index.php?r=post/index
echo Url::to(['@posts']);
echo Url::toRoute('@posts');

Route alias may be useful when your route design is not fixed and you don’t want to change your URL creation code.

Dependent Component Configuration

Properties are added by many components that should be configured to be the ID of a dependent application component like yii\web\CacheSession::cache, yii\caching\DbCache::db.

One can have to configure a property with a configuration array to avoid introducing new application component or for unit testing purpose that can be used for developing the dependent component. You have to do something like below given:

$cache = Yii::createObject([
'class' => 'yii\caching\DbCache',
'db' => [
'class' => 'yii\db\Connection',
'dsn' => '...',
],
]);

Users can have to use the below approach for getting the similar support when developing the latest class that depends on an external factors.

use yii\base\Object;
use yii\db\Connection;
use yii\di\Instance;

class MyClass extends Object
{
public $db = 'db';
public function init()
{
$this->db = Instance::ensure($this->db, Connection::className());
}
}

The db property will be allowed by the above given code to be configured as any of the following initial values:
  • a yii\db\Connection instance;

  • a configuration array that can be used to create a yii\db\Connection instance;

  • a string, representing the ID of an application component.
DatePicker Language Fallback

The language fallback is supported by the yii\jui\DatePicker widget. Such thing is helpful when you configure its language property as the locale ID, which contains variant part and/or region.

For example: Setting the language to be de-DE cannot find a language file available in the widget that named /ui/i18n/datepicker-de-DE.js. Such thing will fall back to the language de and go the language file /ui/i18n/datepicker-de.js.

Passing Validation Errors

Users can have a convenient method addErrors() for the yii\base\Model class that enable to transfer validation errors from one model to another.

For example: if you have a form model class that contains an ActiveRecord model class and you have to pass the form validation errors to the ActiveRecord class by below given method:

use yii\base\Model;
use yii\db\ActiveRecord;
class MyForm extends Model
{
public $model;
public function process()
{
// ...
if (!$this->validate()) {
$this->model->addErrors($this->getErrors());
// ....
}
}
}

Immutable Slug

Make use of a new property named immutable to use yii\behaviors\SluggableBehavior. One cannot changed a slug, if it has been generated before by setting the property though the corresponding source attribute value is changed.

It is advantageous for SEO purpose as you don’t want to change the published URL that uses the slug.

If you are using Yii framework and want to update it with the latest versions, then Hire Yii Developer from Perception System to get affordable Yii Framework Development Services. For more information, visit our official site.
Share this article :

0 comments:

Post a Comment

 
Design by: