3
votes

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.

10
did you try to composer-dumpautoload, clear composer and framework cache(on local), and then reupload to server? - user8506374
It seems to me that you haven't added the service provider to the $providers array in config/app.php - Raza Mehdi

10 Answers

6
votes

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

5
votes

Please run below command and try:

composer update
composer dump-autoload

php artisan config:cache
php artisan cache:clear
2
votes

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

1
votes

replace Datatables with DataTables

1
votes

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]

1
votes

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.

0
votes

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.
0
votes

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
0
votes

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

0
votes

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