Class 'Yajra\DataTables\DatatablesServiceProvider' not found
Asked Answered
C

10

6

I've developed Laravel Project in my local computer. I used Yajra Pakagebox for using bootstrap datatables on it.

Like this : composer require yajra/laravel-datatables-oracle php artisan vendor:publish

Then I pushed them all into Hosting Server but it displays errors like below.

(1/1) FatalThrowableError
Class 'Yajra\DataTables\DatatablesServiceProvider' not found
in ProviderRepository.php (line 208)
at ProviderRepository->createProvider('Yajra\\DataTables\\DatatablesServiceProvider')
in ProviderRepository.php (line 144)
at ProviderRepository->compileManifest(array('Illuminate\\Auth\\AuthServiceProvider', 'Illuminate\\Broadcasting\\BroadcastServiceProvider', 'Illuminate\\Bus\\BusServiceProvider', 'Illuminate\\Cache\\CacheServiceProvider', 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider', 'Illuminate\\Cookie\\CookieServiceProvider', 'Illuminate\\Database\\DatabaseServiceProvider', 'Illuminate\\Encryption\\EncryptionServiceProvider', 'Illuminate\\Filesystem\\FilesystemServiceProvider', 'Illuminate\\Foundation\\Providers\\FoundationServiceProvider', 'Illuminate\\Hashing\\HashServiceProvider', 'Illuminate\\Mail\\MailServiceProvider', 'Illuminate\\Notifications\\NotificationServiceProvider', 'Illuminate\\Pagination\\PaginationServiceProvider', 'Illuminate\\Pipeline\\PipelineServiceProvider', 'Illuminate\\Queue\\QueueServiceProvider', 'Illuminate\\Redis\\RedisServiceProvider', 'Illuminate\\Auth\\Passwords\\PasswordResetServiceProvider', 'Illuminate\\Session\\SessionServiceProvider', 'Illuminate\\Translation\\TranslationServiceProvider', 'Illuminate\\Validation\\ValidationServiceProvider', 'Illuminate\\View\\ViewServiceProvider', 'Yajra\\DataTables\\DatatablesServiceProvider', 'Laravel\\Tinker\\TinkerServiceProvider', 'App\\Providers\\AppServiceProvider', 'App\\Providers\\AuthServiceProvider', 'App\\Providers\\EventServiceProvider', 'App\\Providers\\RouteServiceProvider'))
in ProviderRepository.php (line 61)

The important thing is I can't execute any command on Hosting Server because it is Shared Hosting Server. I saw many articles for solving this problem but they are all using "artisan" and "composer" command. But I can't use this command at all. I can only upload the source code to server with FTP.

Crevice answered 13/10, 2017 at 8:4 Comment(2)
did you try to composer-dumpautoload, clear composer and framework cache(on local), and then reupload to server?Seessel
It seems to me that you haven't added the service provider to the $providers array in config/app.phpOcean
R
11

Depending on what version of DataTables you are using, it may be simple capitalization issue. After version 8 you should use:

Yajra\DataTables\DataTablesServiceProvider

Before version 8 use:

Yajra\Datatables\DatatablesServiceProvider

Upgrade notes reference: https://yajrabox.com/docs/laravel-datatables/master/upgrade#namespace

Ruthie answered 22/3, 2018 at 20:5 Comment(1)
I was doing a copy paste from a tutorial that used capitols for L8, but I'm working in L5.1. Thanks!Jessalyn
H
9

Please run below command and try:

composer update
composer dump-autoload

php artisan config:cache
php artisan cache:clear
Hugo answered 13/10, 2017 at 8:9 Comment(3)
I can't access Hosting Server with SSH.Crevice
I Can't Use "Composer" or "Artisan" because I can't access to Hosting Server with SSH. So I uploaded all source. Please Help Me.Crevice
Thanks, I think some of the dependencies cause this problem to happen, I have run all the above script and it works! *P/S: I deleted vendor folder too.Tip
L
6

It is working for [email protected]

Yajra\DataTables\DataTablesServiceProvider::class,
'Datatables' => Yajra\DataTables\Facades\DataTables::class,

Please add this to the config/app.php file. The first line goes under the "Package Service Providers" section and the second line goes under the "Class Aliases" section

Litt answered 18/1, 2018 at 6:7 Comment(0)
Y
2

replace Datatables with DataTables

Y answered 25/3, 2018 at 20:52 Comment(0)
L
2

In the project's folder

rm -R vendor/
rm -R bootstrap/cache
mkdir bootstrap/cache
chmod -R 777 bootstrap/*

if your laravel version => 5.4

composer require yajra/laravel-datatables-oracle:"~8.0"

if your laravel version => 5.8

composer require yajra/laravel-datatables-oracle:"~9.0"

@config/app.php
'providers' => [
    ...,
    Yajra\DataTables\DataTablesServiceProvider::class,
]

'aliases' => [
    ...,
    'DataTables' => Yajra\DataTables\Facades\DataTables::class,
]

composer dumpautoload
composer install

It works for me.

Source: https://github.com/yajra/laravel-datatables[https://github.com/yajra/laravel-datatables][1]

Linesman answered 6/7, 2020 at 17:44 Comment(1)
Welcome on StackOverflow, please make sure to put code in code boxesThunell
L
2

REASON ITS NOT WORKING IS:

you installed the library. and added it in config/app.php in providers array.

don't forget to run

php artisan vendor:publish

after that.

Leralerch answered 20/10, 2020 at 11:42 Comment(0)
F
1

Re install with the plugin along with the buttons plugin and now it's working. composer require yajra/laravel-datatables-buttons:^3.0

Firstfoot answered 31/1, 2018 at 14:18 Comment(0)
C
0

Try below steps to resolve this issue:

  1. Use composer show to check which version of packages you are using.
  2. Delete all files under bootstrap/cache folder
  3. Delete vendor folder and reinstall all packages using composer install.
Centigram answered 13/10, 2017 at 9:32 Comment(2)
I Can't Use "Composer" or "Artisan" because I can't access to Hosting Server with SSH. So I uploaded all source. Please Help MeCrevice
Do this locally and upload through ftp?Centigram
S
0

all the files you know you're changing to ftp (migrations config controller...)

and replaced local files to server with ftp

/composer.json
/composer.lock
/bootstrap/*
/storage/framework/cache/*
/storage/framework/views/*
/vendor/composer/*
/vendor/autoload.php

If the problem persists, I'm need to relay the version of the Laravel. Tested with

php artisan --version
Laravel Framework 5.4.19
Skardol answered 13/10, 2017 at 9:39 Comment(3)
I can't use any shell command like "artisan" and "composer". Please help me.Crevice
I uploaded completely all source in my local computer.Crevice
@LeeDaniel there is no other solution if it works properly on your local computer and you need to work if you are uploading this working state to the server. And you can use call artisan commands with Artisan::call() in your temp controller. See at laravel.com/docs/5.5/…Skardol
F
0

In your [config/app.php] file, edit the aliases array. Change it from

'Datatables' => Yajra\Datatables\Facades\Datatables::class

to

'Datatables' => Yajra\Datatables\DatatablesServiceProvider::class
Faxen answered 4/3, 2018 at 10:48 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.