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

我与影子孤独终老i 提交于 2019-12-11 11:09:59

问题


I have a problem with laravel and composer package yajra/laravel-datatables Here is my require part from 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 update all passes fine and I can check that inside vendor dir has appeared yajra folder. After that I have add new provider in app.php:

yajra\Datatables\DatatablesServiceProvider::class

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

Class 'yajra\Datatables\DatatablesServiceProvider' not found

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

'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.php file.

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


回答1:


You should use in your app.php

Yajra\Datatables\DatatablesServiceProvider::class

instead of

yajra\Datatables\DatatablesServiceProvider::class

(with capital letter)




回答2:


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,

comoposer update

Solved the issue for me.



来源:https://stackoverflow.com/questions/34696817/composer-laravel-class-yajra-datatables-datatablesserviceprovider-not-found

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!