Yii2 dev digest #7 Apr'14

Apr 16, 2014, 10:07:12 AM

Lucky 7th digest dedicated to Beta release . Not so much really new to say after Beta release notes on Yii site, but I can't stay away :)
Thanks for a big PR campaign by Alexander Makarov (@sam_dark), previous dev digest was seen by more than 5500 people. Quite impressive and gives me more inspiration to make new reviews! As usual - Russian version of this digest is available (see the link above) !
Yii2 beta Release, PSR-2, DI, new RBAC, consistent Url helper, a lot of new widgets

Yii2 Development Visualization

made by Serg Ilin with Gource

Yii2 Extensions

Come on people! Connect your efforts to other great contributors as 2amigos, create and share your extensions. Let's increase Yii2 ecosystem !

Yii2 Tips & Tricks

        $url = ['site/index'];
        $url['Model'] = $model->attributes;
        echo Url::to($url);
backend\models\ArticleData (extends from common\models\ArticleData)
frontend\models\ArticleData (extends from common\models\ArticleData)

This way I can re-use this relation both from backend and frontend without re-declaring

$calledClass = static::className();
$nsPosition = strrpos($calledClass, '\\');
$calledNS = substr($calledClass, 0, $nsPosition);
return $this->hasMany(forward_static_call([$calledNS . '\ArticlesData', 'className']), ['bla' => 'bla_id']);
'request'=> [
            'class' => '\yii\web\Request',
            'hostInfo' => $params['backendUrl'],
            'baseUrl' => $params['backendUrl'],

or mock $_SERVER somewhere in app bootstrap

$_SERVER['SERVER_NAME'] = 'mydomain.com';
$_SERVER['HTTP_HOST'] = 'mydomain.com';
 namespace app\models;

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

 interface UserFinderInterface
     function findUser();

 class UserFinder extends Object implements UserFinderInterface
     public $db;

     public function __construct(Connection $db, $config = [])
         $this->db = $db;

     public function findUser()

 class UserLister extends Object
     public $finder;

     public function __construct(UserFinderInterface $finder, $config = [])
         $this->finder = $finder;

 $container = new Container;
 $container->set('yii\db\Connection', [
     'dsn' => '...',
 $container->set('app\models\UserFinderInterface', [
     'class' => 'app\models\UserFinder',
 $container->set('userLister', 'app\models\UserLister');

 $lister = $container->get('userLister');

 // which is equivalent to:

 $db = new \yii\db\Connection(['dsn' => '...']);
 $finder = new UserFinder($db);
 $lister = new UserLister($finder);

Read previous digests

comments powered by Disqus
Kuzminov "iJackUA"
Web Team Lead
at MobiDev (Kharkiv, Ukraine)
Code in Ruby and Elixir, but still love PHP. Explore ES6 and Vue.js. Explore databases, use Ubuntu and MacOS, think about IT people and management


Skaffold tool that facilitates continuous development for Kubernetes-native applications. Continuously deploys to your local or remote Kubernetes cluster.

DoItLive is a tool for live presentations in the terminal. It reads a file of shell commands and replays the commands in a fake terminal session as you type random characters.