Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

trh88's avatar
Level 1

Class not found after deployment

I have deployed my app to my staging environment. All is working absolutely fine on my local (homestead) environment.

After deployment I am seeing the error

Class 'Datatables' not found in /var/www/xxx/production/app/Http/Controllers/DatatablesController.php

(This is using the Laravel Datatables package, but I think it's a more general issue rather than package specific).

Have I missed a step?

  • run composer install --no-dev
  • run composer dump-autoload
  • run php artisan optimize
  • I can see the config file datatables.php so I know the installation is successful
  • I can see the folder in vendor called yajra which contains the vendor stuff, all looks fine
  • I even checked vendor/composer/autoload_classmap.php to check the classes are there

But still no joy! Any help much appreciated!

0 likes
8 replies
zachleigh's avatar

Have you tried clearing the cache?

composer clearcache
php artisan cache:clear
tomopongrac's avatar

Does in composer.json package is in require section, not in require-dev section...

trh88's avatar
Level 1

@tomi - Yep, in the require section (otherwise it wouldn't have installed on --no-dev)

zachleigh's avatar

What does you Datatables controller look like?

trh88's avatar
Level 1

@zachleigh

use Datatables;

return Datatables::of($customers).....

Like I say, this all works fine on my local environment.

app.php:

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

Service Provider - Yajra\Datatables\DatatablesServiceProvider::class,

Snapey's avatar

Typical case-insensitive to case-sensitive environment issue. Check the casing of your files and folders.

2 likes
trh88's avatar
trh88
OP
Best Answer
Level 1

php artisan config:cache fixed it, for some reason! Thanks!

Please or to participate in this conversation.