laravel 找不到类“Maatwebsite\Excel\Excel”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/50551149/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 17:45:25  来源:igfitidea点击:

Class 'Maatwebsite\Excel\Excel' not found

phplaravel

提问by S.M_Emamian

my composer.json:

我的composer.json

    ...
    "maatwebsite/excel": "^3.0",
    ...

I can run my project on localhost but when I upload on server I got this error message:

我可以在本地主机上运行我的项目,但是当我在服务器上上传时,我收到以下错误消息:

Class 'Maatwebsite\Excel\Excel' not found

my laravel version:

我的 Laravel 版本:

Laravel Framework 5.5.40

my public directory:

我的公共目录:

enter image description here

在此处输入图片说明

public_html/public/index.php

public_html/public/index.php

<?php

/**
 * Laravel - A PHP Framework For Web Artisans
 *
 * @package  Laravel
 * @author   Taylor Otwell <[email protected]>
 */

/*
|--------------------------------------------------------------------------
| Register The Auto Loader
|--------------------------------------------------------------------------
|
| Composer provides a convenient, automatically generated class loader for
| our application. We just need to utilize it! We'll simply require it
| into the script here so that we don't have to worry about manual
| loading any of our classes later on. It feels great to relax.
|
*/


require __DIR__.'/../bootstrap/autoload.php';
/*
|--------------------------------------------------------------------------
| Turn On The Lights
|--------------------------------------------------------------------------
|
| We need to illuminate PHP development, so let us turn on the lights.
| This bootstraps the framework and gets it ready for use, then it
| will load up this application so that we can run it and send
| the responses back to the browser and delight our users.
|
*/

$app = require_once __DIR__.'/../bootstrap/app.php';

/*
|--------------------------------------------------------------------------
| Run The Application
|--------------------------------------------------------------------------
|
| Once we have the application, we can handle the incoming request
| through the kernel, and send the associated response back to
| the client's browser allowing them to enjoy the creative
| and wonderful application we have prepared for them.
|
*/

$kernel = $app->make(Illuminate\Contracts\Http\Kernel::class);

$response = $kernel->handle(
    $request = Illuminate\Http\Request::capture()
);

$response->send();

$kernel->terminate($request, $response);

my website:

我的网站:

http://alsatmarketing.com/

http://alsatmarketing.com/

updated

更新

I get this error after run composer require maatwebsite/excel:^3.0:

运行后我收到此错误composer require maatwebsite/excel:^3.0

 Problem 1
    - Installation request for maatwebsite/excel 3.0 -> satisfiable by maatwebsite/excel[3.0.0].
    - Conclusion: remove laravel/framework v5.5.40
    - Conclusion: don't install laravel/framework v5.5.40
    - maatwebsite/excel 3.0.0 requires illuminate/support ^5.6 -> satisfiable by illuminate/support[v5.6.0, v5.6.1, v5.6.10, v5.6.11, v5.6.12, v5.6.13, v5.6.14, v5.6.15, v5.6.16, v5.6.17,
v5.6.19, v5.6.2, v5.6.20, v5.6.21, v5.6.22, v5.6.23, v5.6.3, v5.6.4, v5.6.5, v5.6.6, v5.6.7, v5.6.8, v5.6.9].
    - don't install illuminate/support v5.6.4|don't install laravel/framework v5.5.40
    - don't install illuminate/support v5.6.5|don't install laravel/framework v5.5.40
    - don't install illuminate/support v5.6.6|don't install laravel/framework v5.5.40
    - don't install illuminate/support v5.6.7|don't install laravel/framework v5.5.40
    - don't install illuminate/support v5.6.0|don't install laravel/framework v5.5.40
    - don't install illuminate/support v5.6.1|don't install laravel/framework v5.5.40
    - illuminate/support v5.6.10 conflicts with laravel/framework[v5.5.40].
    - illuminate/support v5.6.11 conflicts with laravel/framework[v5.5.40].
    - illuminate/support v5.6.12 conflicts with laravel/framework[v5.5.40].
    - illuminate/support v5.6.13 conflicts with laravel/framework[v5.5.40].
    - illuminate/support v5.6.14 conflicts with laravel/framework[v5.5.40].
    - illuminate/support v5.6.15 conflicts with laravel/framework[v5.5.40].
    - illuminate/support v5.6.16 conflicts with laravel/framework[v5.5.40].
    - illuminate/support v5.6.17 conflicts with laravel/framework[v5.5.40].
    - illuminate/support v5.6.19 conflicts with laravel/framework[v5.5.40].
    - don't install illuminate/support v5.6.2|don't install laravel/framework v5.5.40
    - illuminate/support v5.6.20 conflicts with laravel/framework[v5.5.40].
    - illuminate/support v5.6.21 conflicts with laravel/framework[v5.5.40].
    - illuminate/support v5.6.22 conflicts with laravel/framework[v5.5.40].
    - illuminate/support v5.6.23 conflicts with laravel/framework[v5.5.40].
    - don't install illuminate/support v5.6.3|don't install laravel/framework v5.5.40
    - illuminate/support v5.6.8 conflicts with laravel/framework[v5.5.40].
    - illuminate/support v5.6.9 conflicts with laravel/framework[v5.5.40].
    - Installation request for laravel/framework (locked at v5.5.40, required as 5.5.*) -> satisfiable by laravel/framework[v5.5.40].


Installation failed, reverting ./composer.json to its original content.

回答by Quezler

Try running:

尝试运行:

composer require maatwebsite/excel:^3.0.1

composer require maatwebsite/excel:^3.0.1

(the commands in the comments of the question will likely complain about lock files)

(问题评论中的命令可能会抱怨锁定文件)