5

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.

Sangwin Gawande
  • 7,658
  • 8
  • 48
  • 66
Lee Chang Jian
  • 51
  • 1
  • 1
  • 7
  • did you try to `composer-dumpautoload`, clear composer and framework cache(on local), and then reupload to server? –  Oct 13 '17 at 08:09
  • It seems to me that you haven't added the service provider to the `$providers` array in `config/app.php` – Raza Mehdi Oct 13 '17 at 13:27

10 Answers10

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

shuadoc
  • 436
  • 4
  • 5
9

Please run below command and try:

composer update
composer dump-autoload

php artisan config:cache
php artisan cache:clear
halfer
  • 19,824
  • 17
  • 99
  • 186
AddWeb Solution Pvt Ltd
  • 21,025
  • 5
  • 26
  • 57
5

It is working for v@8.3

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

Ravi
  • 86
  • 6
Priya
  • 1,410
  • 14
  • 22
2

replace Datatables with DataTables

1

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

Rayees Pk
  • 2,503
  • 1
  • 23
  • 19
1

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]

Andy
  • 12,859
  • 5
  • 41
  • 56
Alan Viera
  • 11
  • 1
1

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.

Aditya Tomar
  • 841
  • 1
  • 13
  • 20
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.
Lars Mertens
  • 1,389
  • 2
  • 15
  • 37
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
Qh0stM4N
  • 182
  • 1
  • 9
  • I can't use any shell command like "artisan" and "composer". Please help me. – Lee Chang Jian Oct 13 '17 at 09:44
  • I uploaded completely all source in my local computer. – Lee Chang Jian Oct 13 '17 at 09:44
  • @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 https://laravel.com/docs/5.5/artisan#programmatically-executing-commands – Qh0stM4N Oct 13 '17 at 17:56
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
Rafid Shahriar
  • 98
  • 1
  • 1
  • 11