Yii2 dev digest #8 May-Jun'14 > stdout.in Ievgen Kuzminov IT blog

Yii2 dev digest #8 May-Jun'14

Jun 10, 2014, 7:57:23 PM

May was a good time for a barbeque and trekking :) So here is a brief digest, hopefully not so much news means more bugfix and docs work from Yii Team towards stable RC.

Try Yii2 in one click with Vagrant VM + Ansible provisioning

See all details in my previous post.. All software you wanted to try with Yii2 installed and provisioned out of the box.
In two words :
"Try Yii2" provides you with Vagrant file and Ansible provsioning scripts. Vagrant will launch the VirtualBox VM, download OS image, deploy it and then run Ansible. It will set up all needed software inside Linux VM, clone Yii2 project, download test DB and connect it with project. Also Vagrant will modify you hosts file and assign special local domain adresses with VM IP address, so you will be able to access test Yii2 prject by humanreadable local domain name. All these steps will be made completely automatically, just run vagrant up and wait !

Yii2 Extensions

Yii2 Tips & Tricks

$handler = new \app\components\ApiErrorHandler;
        \Yii::$app->set('errorHandler', $handler);
        $handler->register();
'rules' => [
       [ 
                   'class' => 'yii\rest\UrlRule',
                   'controller' => 'user', 
                   'tokens' => ['{id}' => '<id:[a-z0-9]*>']
                   ],
          ],
  • How can i pass params for layout for breadcrumbs?

    In controller: $this->view->params['breadcrumbs'] = [...]; In view: print_r($this->params['breadcrumbs']);

  • How do i include image file using assets?

    After you call $bundle = YourAssetBundle::register($this);, you can use $bundle->baseUrl and prefix it to the image path in the image tag. Yii won't do automatic replacement like you said. Unless you are developing an extension, you normally don't need to put images in an asset bundle. You should directly put them under Web accessible folders.

Read previous digests

comments powered by Disqus
Ievgen
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

Notes


Did you know ? Vagrant (1.5+) "Error: Remote connection disconnect. Retrying..." while loading is not a bug. It just try to detect when VM is loaded. Yep... very confusing.



Slick - really looks like "the last JS carousel you'll ever need". Responsive, touch-enabled, mouse-dragging, dynamic add/remove.



Tried yii2-pjax widget on blog. A few moment of work and you can navigate through Notes without page reload. Really cool!