Monday, 24 November 2014

Yii2: createUrl method

Old Yii1 to create an url we write:

$this->createUrl(); 
or
Yii::app()->createUrl();

Now with Yii2 we have to write

\Yii::$app->getUrlManager()->createUrl(['controler/action','param1'=>'value1','param2'=>'value2']);


Yii2: Error invalid configuration with modules

Error: 
Invalid Configuration – yii\base\InvalidConfigException
The configuration for the "modules" component must contain a "class" element.
Solution: 
Check your config file.  don't put "modules" in component section.
Correct config:
'components'=>[
...
],
'modules'=>[
...
]

Readmore about module : https://github.com/yiisoft/yii2/blob/master/docs/guide/structure-modules.md