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 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
  • ¥15 数据可视化Python
  • ¥15 要给毕业设计添加扫码登录的功能!!有偿
  • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘