Yii2 crib sheet (until I create some proper pages)

By | December 15, 2015

Creating URL

Old way (Yii 1.0 maybe??)

$url = Yii::$app->controller->createUrl(‘xx’);// your own url generation logic

New way (Yii 2.0 )

$url = \Yii::$app->getUrlManager()->createUrl(‘consignment/label’);

Creating controllers

2015_12_15_11_40_14_Controller_Generator

2016_01_19_21_31_55_Form_Generator

Debugging (old skool)

Yii::info(“My message” , ‘scsdebug’);
Yii::warning(“this->consignment_date=” . $this->consignment_date , ‘scsdebug’);
Yii::warning(\DateTime::createFromFormat(‘d/m/Y’, $this->consignment_date) , ‘scsdebug’);

Category: Yii