Laravel PHPExcel更新中的模糊类解析问题

11
我尝试通过php excel更新laravel,但在安装时我发现composer显示以下警告。

Error:


Error:

Warning: Ambiguous class resolution, "SettingsController" was found in both 

"C:\xampp\htdocs\mti\app\controllers\SettingsController.php" and 

"C:\xampp\htdocs\mti\app\controllers\SettingsControllerBackup.php", the first 

will be used.Warning: Ambiguous class resolution, "ClassModel" was found in both

"C:\xampp\htdocs\mti\app\models\ClassModel.php" and "C:\xampp\htdocs\mti\

app\models\LoginModel.php", the first will be used.

设置控制器:

<?php

class SettingsController extends BaseController
{

    public function ChangePasswordLayout()
    {
        return View::make('settings/changepassword/changepassword');
    }

    public function ChangePasswordProcess()
    {
        $PasswordData = Input::all();

        Validator::extend('pwdvalidation', function($field, $value, $parameters)
        {
            return Hash::check($value, Auth::user()->password);
        });

        $messages = array('pwdvalidation' => 'The Old Password is Incorrect');

        $validator = Validator::make($PasswordData, User::$rulespwd, $messages);
        if ($validator->passes()) 
        {
            $user = User::find(Auth::user()->id);
            $user->password = Hash::make(Input::get('NewPassword'));
            $user->save();
            return Redirect::to('changepassword')->withInput()->with('Messages', 'The Password Information was Updated');
        } else 
        {
            return Redirect::to('changepassword')->withInput()->withErrors($validator);
        }

    }

    public function ProfileLayout()
    {
        $user = Auth::user()->id;
        $ProfileDetailsbyid = ProfileModel::where('id', $user)->get()->toArray();   
        return View::make('settings/profile/profile')->with('ProfileDetailsbyid', $ProfileDetailsbyid);
    }

    public function ProfileUpdateProcess($data=NULL)
    {

    $user = Auth::user()->id;
    $ProfileDetailsbyid = ProfileModel::where('id', $user)->get()->toArray();

        $ProfileData = array_filter(Input::except(array('_token')));

      $validation  = Validator::make($ProfileData, ProfileModel::$rules);        
        if ($validation->passes()) 
        {

        if(!empty($ProfileData['Photo']))
    {
    Input::file('Photo')->move('assets/uploads/profilephoto/', $user . '-Photo.' . Input::file('Photo')->getClientOriginalName());
    $Photo=$user.'-Photo.' . Input::file('Photo')->getClientOriginalName();
    unset($ProfileData['Photo']);
    $ProfileData['Photo']=$Photo;
    }

           $affectedRows = ProfileModel::where('id', $user)->update($ProfileData);
            //VehicleModel::create($VehicleData);
            return Redirect::to('profile')->with('Message', 'Profile Details Update Succesfully')->with('ProfileDetailsbyid', $ProfileDetailsbyid);
        } else 
        {

            return Redirect::to('profile')->withInput()->withErrors($validation->messages())->with('ProfileDetailsbyid', $ProfileDetailsbyid);
        }
    }


}

ClassModel:

<?php
class ClassModel extends Eloquent
{

    protected $primaryKey = 'AutoID';
    protected $created_at = 'CreatedAt';
    protected $updated_at = 'UpdatedAt';
    protected $table = 'class';
    protected $guarded = array('GradeName');
    protected $fillable = array('GradeName');

    public function batch(){
        return $this->hasMany('BatchModel', 'Class');
    }

    public function studentadmissionresult(){
        return $this->hasMany('StudentAdmissionModel', 'StudentCourse');
    }

    public $timestamps = true;



    public static $rules = array(
        'GradeName' =>  array('required', 'unique:class','regex:/^./'),
        'GradeSection' => 'required',
        'GradeCode' => array('required', 'unique:class')
                             );
     public static $updaterules = array(
        'GradeName' =>  array('required','regex:/^./'),
        'GradeSection' => 'required',
        'GradeCode' => array('required')
                             );                      

}

我按照这个教程进行操作:

https://github.com/Maatwebsite/Laravel-Excel

我尝试了以下命令:

composer require maatwebsite/excel": "~1.2.1
1个回答

17

这实际上与您正在安装的软件包无关。

解释

在更新后重新创建自动加载文件(composer dump-autoload)时,Composer 检测到您有两个具有完全相同名称的类(但位于不同的文件中)。

SettingsController.phpSettingsControllerBackup.php中的类SettingsController

ClassModel.phpLoginModel.php中的类ClassModel

然后,Composer 将选择使用其中之一(我不确定它是如何做出决定的,可能只是使用它找到的第一个)并将忽略其他发生的情况。 - 确认。Composer 会使用第一个匹配项

解决方案

  1. 如果您不需要这些文件,请删除它们
  2. 重命名类

一个好的常见做法是将类命名为文件名。这是避免此类冲突的一种简单方式,因为同一目录下的两个文件不能具有相同的名称。


当我使用符号链接作为我的供应商目录时,遇到了这个问题。有没有办法排除供应商要查看的目录? - Jonas de Herdt
抱歉,我不再从事太多PHP开发工作了。请提出一个新问题,我相信其他人一定能够帮助你。 - lukasgeiter

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接