dqy1265 2015-11-18 00:49
浏览 79
已采纳

尝试将yii2项目上传到服务器时出错

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 'Class yii\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条回答 默认 最新

  • dtkl55257 2015-11-18 03:32
    关注

    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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 宇视监控服务器无法登录
  • ¥15 PADS Logic 原理图
  • ¥15 PADS Logic 图标
  • ¥15 电脑和power bi环境都是英文如何将日期层次结构转换成英文
  • ¥20 气象站点数据求取中~
  • ¥15 如何获取APP内弹出的网址链接
  • ¥15 wifi 图标不见了 不知道怎么办 上不了网 变成小地球了
  • ¥50 STM32单片机传感器读取错误
  • ¥50 power BI 从Mysql服务器导入数据,但连接进去后显示表无数据
  • ¥15 (关键词-阻抗匹配,HFSS,RFID标签天线)