rinat.io


Yii2 Preview and Composer

Great news - Yii2 in town! I decided to spend some time and switch this site for it. I use composer for dependencies and since Yii2 doesn't support it yet I added repository definition by myself. Here's what I came up with:

Since there's no documentation for Yii2 yet, upgrading was tricky sometimes. This slideshare helped me a lot. Also built in demo app was very useful. Here're some notes:

  • Everything under namespaces (except Yii and YiiBase classes which is questionable)
  • $this isn't instance of current controller in views. It's instance of \yii\base\View class with bunch of interesting methods like beginPage, head, beginBody etc. You still can access controller through $this->context.
  • Asset manager supports bundles that looks promising but I wasn't able to figure out how to forcePublish them on development environment and it doesn't have old excludeFiles.
  • You have to use echo $this->render('view') in controller actions
  • For rendering partials in view you can use echo $this->render('_partial') which is the same as echo $this->context->renderPartial('_partial')

Still cannot figure out how to set up logger...

I haven't spent too much time playing with it, so I might be wrong somewhere. Definitely a lot of stuff was changed and a lot of stuff will be changed, and it certainly looks interesting and surely going to be fun!

UPD: They needed 3 days, now you can download yii2 from packagist.

P.S.: Here's a simple yii2 kickstart app on github. Comments are welcome!