未找到 Composer Laravel 类“yajra\Datatables\DatatablesServiceProvider”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/34696817/
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 13:01:12  来源:igfitidea点击:

Composer Laravel Class 'yajra\Datatables\DatatablesServiceProvider' not found

phplaravelnamespacescomposer-php

提问by gandra404

I have a problem with laraveland composer packageyajra/laravel-datatablesHere is my require part from composer.json:

我有一个laravelcomposer packageyajra/laravel-datatables的问题, 这是我需要的部分composer.json

"require": {
    "php": ">=5.5.9",
    "laravel/framework": "5.2.*",
    "cartalyst/sentinel": "^2.0",
    "laravelcollective/html": "^5.2",
    "yajra/laravel-datatables-oracle": "^6.1"
},

After executing composer updateall passes fine and I can check that inside vendor dir has appeared yajra folder. After that I have add new provider in app.php:

执行composer update完所有通过后,我可以检查供应商目录中是否出现了 yajra 文件夹。之后,我在 app.php 中添加了新的提供程序:

yajra\Datatables\DatatablesServiceProvider::class

and then run php artisan but followingerror appears in the console:

然后运行 ​​php artisan 但控制台中出现以下错误:

Class 'yajra\Datatables\DatatablesServiceProvider' not found

I can fix this error by editing autoload_classmap.phpfile and manually add

我可以通过编辑autoload_classmap.php文件并手动添加 来修复此错误

'yajra\Datatables\DatatablesServiceProvider' => $vendorDir . '/yajra/laravel-datatables-oracle/src/DatatablesServiceProvider.php',

Anyway, the next time I execute composer update this line is deleted and again appears the same error and I again have to manually edit autoload_classmap.phpfile.

无论如何,下次我执行 composer update 时,该行被删除并再次出现相同的错误,我再次必须手动编辑autoload_classmap.php文件。

There is something wrong which causes composer updateto not update relevant autoload files. I can not get it what is going on.

有一些错误导致composer update不更新相关的自动加载文件。我不明白这是怎么回事。

回答by Marcin Nabia?ek

You should use in your app.php

你应该在你的 app.php

Yajra\Datatables\DatatablesServiceProvider::class

instead of

代替

yajra\Datatables\DatatablesServiceProvider::class

(with capital letter)

(带大写字母)

回答by Rashmi Jain

Try removing syntactic sugar operators like tilde and caret sign in composer.json. Because sometimes they do not allow the exact version to install. The same problem happened to me also. Then run,

尝试删除 composer.json 中的语法糖操作符,如波浪号和插入符号。因为有时他们不允许安装确切的版本。同样的问题也发生在我身上。然后跑,

comoposer update

Solved the issue for me.

为我解决了这个问题。