问题
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