Hi All,
I am currently following the post tutorial for Yii2 using the basic app. it says to add:
public function behaviors()
{
return array(
'timestamp' => array(
'class' => 'yii\behaviors\AutoTimestamp'
)
);
}
Below that but it doesnot work:
public function rules()
{
return [
[['title', 'data', 'create_time', 'update_time'], 'required'],
[['data'], 'string'],
[['create_time', 'update_time'], 'integer'],
[['title'], 'string', 'max' => 255]
];
}
I keep getting this error when I create a post:
ReflectionException
Class yii\behaviors\AutoTimestamp does not exist
1. in C:\wamp\www\yii2\vendor\yiisoft\yii2\di\Container.php at line 408
399400401402403404405406407408409410411412413414415416417 * @return array the dependencies of the specified class.
*/
protected function getDependencies($class)
{
if (isset($this->_reflections[$class])) {
return [$this->_reflections[$class], $this->_dependencies[$class]];
}
$dependencies = [];
$reflection = new ReflectionClass($class);
$constructor = $reflection->getConstructor();
if ($constructor !== null) {
foreach ($constructor->getParameters() as $param) {
if ($param->isDefaultValueAvailable()) {
$dependencies[] = $param->getDefaultValue();
} else {
$c = $param->getClass();
$dependencies[] = Instance::of($c === null ? null : $c->getName());
Any idea why please?
Thank you,
Ben