I am creating a test project with Yii2 and trying to use the timestamp behavior but having a hard time implementing it. I have created the model and CRUD for the table market and have attempted to add a behavior to models/Market.php as follows:
class Market extends \yii\db\ActiveRecord
public function behaviors()
'timestamp' => [
'class' => TimestampBehavior::className(),
'attributes' => [
ActiveRecord::EVENT_BEFORE_INSERT => ['created_at', 'updated_at'],
ActiveRecord::EVENT_BEFORE_UPDATE => 'updated_at',
However, when loading the page I get the error
Class 'yii\behaviors\TimestampBehavior' not found
I’ve searched the whole source code including vendor/yiisoft but there is no class of TimestempBehavior anywhere. Do I need to include/install it some other way first?
I initially installed Yii2 using Composer and I can see that it is alpha. Generally with Composer I would type ‘composer update’ to update but this doesn’t change anything. How would I go about upgrading to a newer version?