Laravel-datatables: Laravel Datatables.net get Class datatables does not exist error

Created on 23 Feb 2016  ·  17Comments  ·  Source: yajra/laravel-datatables

after install this package on laravel i get this error:

ReflectionException in Container.php line 738: 
Class datatables does not exist

Install:

composer require yajra/laravel-datatables-oracle

configuration on app.php:

'providers' => [
    ...
    yajra\Datatables\DatatablesServiceProvider::class,
],

'aliases' => [
    ...
    'Datatables' => yajra\Datatables\Datatables::class,
],

run publish command:

php artisan vendor:publish

route:

Route::get('profitsData', 'ReportProfitsController@data');

controller:

namespace App\Http\Controllers;
use Yajra\Datatables\Datatables;

class ReportProfitsController extends Controller
{
    public function data()
    {
        return Datatables::of(User::select('*'))->make(true);
    }
}

‍‍‍```
composer dump-autoload


Most helpful comment

If someone come to this post using datatables 8 take into consideration that the package namespace was updated from YajraDatatables to YajraDataTables. with an UpperCase T.

All 17 comments

Please use Yajra\Datatables\DatatablesServiceProvider::class as service provider and no need to add a facade/alias.

'providers' => [
    ...
    Yajra\Datatables\DatatablesServiceProvider::class,
],

after change to that and remove from alias, problem not solved :(

What version of the package and Laravel are you using? Were you able to remove the alias?

​Laravel:

"laravel/framework": "5.2.*",

datatables:

"yajra/laravel-datatables-oracle": "^6.6.0"

I added datatable to alias again

no any body can help me? :(

Are you upgrading from lower version? Try deleting the vendor folder then do composer update.

--Edit--
yajra namespace is from version 5 and below. Since v6, new namespace is Yajra (capital Y).

Ohhhh my God!!!! DONT resolved :| :| :|

do you have other solution about this problem? :(

Hmmm. Maybe it's the cache causing the issue? Try deleting bootstrap/cache/services.php then reinstall all the packages?

​i use newest version of this package and i don't have that already,remove
service.php file and reinstall that dont resolve my problem :(

From SO. http://stackoverflow.com/questions/33122553/class-datatables-does-not-exist-error-when-using-yajra-laravel-datatables

1.first rename your project to a new name.
2.use composer update
3.run php artisan config:cache
4.and run php artisan cache:clear

i have same problem.... and can't solve this problem :(

@tux-world @wahyusigit, were you able to resolve this issue? Have you tried the suggestions from SO? Thanks!

I found this was fixed by changing "minimum-stability" to "stable" from "dev" because composer was trying to pull in "6.0.0-alpha" instead of the latest stable "6.20.0". Maybe this will help.

same error has also happened if you don't have conf/datatables.php. try installing latest or above 7.x

composer require yajra/laravel-datatables-oracle

add these lines in config/app.php

 Yajra\Datatables\DatatablesServiceProvider::class,

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

 php artisian config:cache

if you don't have file config/datables.conf. Try to paste these file there.
https://gist.github.com/hsali/1cab0d6c81020bf7bce043b65f94373a

If someone come to this post using datatables 8 take into consideration that the package namespace was updated from YajraDatatables to YajraDataTables. with an UpperCase T.

@price2b thank you. You're right.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

hohuuhau picture hohuuhau  ·  3Comments

t0n1zz picture t0n1zz  ·  3Comments

sangnguyenplus picture sangnguyenplus  ·  3Comments

alejandri picture alejandri  ·  3Comments

hari-web picture hari-web  ·  3Comments