Custom model properties

I’m trying to get my head ahead models in 2.0 and getting stuck with something really basic! I have some functions on a model, some static some not, but if i try and access them i just get this error

Call to undefined method Yii::app()

I’m trying to access them either like this


(in 1.x I would have something like MyModel::model()->myFunction();


$model= new MyModel();


Can’t seem to get either to work at all but must be doing something silly…?

you should read the docs for yii2


// use this instead



// has been renamed to 


// however this should work fine

$model= new MyModel();


Thanks, just so I can read up where is the first point you mention in the docs? I looked at the model section of the guide to 2.0 but didn’t spot that point.

hey oaks I dont think the first one is under models but you will find many cases where it has been used and talked about throughout

for instance in create action its being used to get data from request component