I'm trying to upload my Yii2 project to a server. When I try to load index.php
in the web folder, I got an error:
yii\base\Exception
with message 'Classyii\base\model
not found'.
I understand that Yii2 haven't found the model, but I don't know why it happened. I can't also get in the other views. Do I need to change something else in the code?
This is Buscar model
contents.
class Buscar extends model // This is line 6 that was mentioned in the error
{
public $q, $m, $t, $p, $a;
public function rules()
{
return[
["q", "match", "pattern" => '/^[0-9a-záéíóúñ\s]+$/i', 'message' => 'Sólo se aceptan letras y numeros'],
["m", "match", "pattern" => '/^[0-9a-záéíóúñ\s]+$/i', 'message' => 'Sólo se aceptan letras y numeros'],
["t", "match", "pattern" => '/^[0-9a-záéíóúñ\s]+$/i', 'message' => 'Sólo se aceptan letras y numeros'],
["p", "match", "pattern" => '/^[0-9a-záéíóúñ\s]+$/i', 'message' => 'Sólo se aceptan letras y numeros'],
["a", "match", "pattern" => '/^[0-9a-záéíóúñ\s]+$/i', 'message' => 'Sólo se aceptan letras y numeros'],
];
}
public function attributeLabels()
{
return [
'q' => "Buscar:", //esto aparece en index
'm' => "Buscar Monografia:",
't' => "Buscar Tesis:",
'p' => "Buscar Publicacion Periodica:",
'a' => "Buscar Articulos:"
];
}
...
}
I don't know if the error is in extends model
and should be extends Model
?
1) Use yii\base\Model
instead of yii\base\model
, can be a problem with case. There are huge difference between Windows and Unix, it's highly recommended to have the same environment on local and production servers.
2) Make sure that you installed composer packages and autoload file was created.