laravel-datatables: Class 'Yajra\Datatables\Facades\Datatables' not found

Hello, Why i get this error :

Class 'Yajra\Datatables\Facades\Datatables' not found

Cause i never update anything.

My app.php is :

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

How to fix that?

About this issue

  • Original URL
  • State: closed
  • Created 9 years ago
  • Reactions: 2
  • Comments: 32 (5 by maintainers)

Most upvoted comments

@shairozan, the Facade file was removed on v6.0 and an alias was automatically registered in the service provider. You need to replace this use Yajra\Datatables\Facades\Datatables to just use Datatables or use Yajra\Datatables\Datatables instead for better IDE support.

@idmeneo sorry for the inconvenience. What are steps have you done so far? Are using a fresh installation or upgrading a project?

Some tips:

  1. Use composer show to double check which version of packages you are using.
  2. Delete all files under bootstrap/cache folder as suggested by @RBBarani.
  3. Delete vendor folder and reinstall all packages using composer install.

– Edit – “yajra” and “Yajra” namespace is a bit old issue from v5.x and below and I think is irrelevant on v7. Thanks!

On v8, Run composer update and use this namespace use Yajra\DataTables\Facades\DataTables;

Namespace and class name were updated on v8. Use DataTables instead of Datatables.

That worked

@wisnuvb Namespace and class name were updated on v8. Use DataTables instead of Datatables. See upgrade guide for ref.

just delete all files inside a bootstrap->cache folder. And run your project. Bug fixed.

dev-develop uses Yajra\Datatables namespace which will be tagged as v6.0.0. For the facade, please use 'Datatables' => Yajra\Datatables\Datatables::class, atm.

Change follwoing

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

to this

yajra\Datatables\DatatablesServiceProvider::class,
'Datatables' => yajra\Datatables\Datatables::class,

and try.

This is use Yajra\DataTables\Facades\DataTables; working fine from my side thanks

Changing from v6.0 to v8.0 forced me to change config/app.php frro

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

to

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

and it worked fine afterwards.

Also, if used to automatically un-escape html elements, you’d have to publish the vendor package and change config/datatables.php

       /*
         * List of columns to be escaped. If set to *, all columns are escape.
         * Note: You can set the value to empty array to disable XSS protection.
         */
         'escape' => '*',

to

        'escape' => [],

I use composer require yajra/laravel-datatables-oracle command and change below line yajra\Datatables\DatatablesServiceProvider::class, ‘Datatables’ => yajra\Datatables\Datatables::class, It,s working. Something like this https://appdividend.com/2018/04/16/laravel-datatables-tutorial-with-example/

Thx for the answer. I finally got it working by downgrading your module to v6.2 and updating all the other libraries.

Yajra\DataTables\DataTablesServiceProvider::class, in providers array Yajra\DataTables\Facades\DataTables::class, in aliases array

use this one, it solved the issue for me

Use this:

‘Datatables’ => Yajra\DataTables\Facades\DataTables::class, // Datatable

D and T should be capital.

@victorsteven’s solution worked on a fresh Laravel 5.6 + Datatables 8.7.0

@lexxyungcarter please see upgrade guide for ref.