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 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!
  • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?
  • ¥15 求daily translation(DT)偏差订正方法的代码
  • ¥15 js调用html页面需要隐藏某个按钮
  • ¥15 ads仿真结果在圆图上是怎么读数的
  • ¥20 Cotex M3的调试和程序执行方式是什么样的?
  • ¥20 java项目连接sqlserver时报ssl相关错误
  • ¥15 一道python难题3
  • ¥15 牛顿斯科特系数表表示