Lee Chang Jian
Lee Chang Jian

Reputation: 61

Class 'Yajra\DataTables\DatatablesServiceProvider' not found

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.

Upvotes: 6

Views: 41607

Answers (10)

Priya
Priya

Reputation: 1470

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

Upvotes: 6

Aditya Tomar
Aditya Tomar

Reputation: 890

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.

Upvotes: 2

Alan Viera
Alan Viera

Reputation: 21

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]

Upvotes: 2

replace Datatables with DataTables

Upvotes: 2

Rafid Shahriar
Rafid Shahriar

Reputation: 98

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

Upvotes: 0

shuadoc
shuadoc

Reputation: 446

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

Upvotes: 11

Rayees Pk
Rayees Pk

Reputation: 2983

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

Upvotes: 1

AddWeb Solution Pvt Ltd
AddWeb Solution Pvt Ltd

Reputation: 21681

Please run below command and try:

composer update
composer dump-autoload

php artisan config:cache
php artisan cache:clear

Upvotes: 9

Qh0stM4N
Qh0stM4N

Reputation: 192

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

Upvotes: 0

Lars Mertens
Lars Mertens

Reputation: 1439

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.

Upvotes: 0

Related Questions