Uncaught ReflectionException: Class "config"

Yesterday the application was working perfectly.
Today when I opened it, I got this error

Blockquote Fatal error: Uncaught ReflectionException: Class “config” does not exist in /home/jtrictez/public_html/admin/ninja/vendor/laravel/framework/src/Illuminate/Container/Container.php:959 Stack trace: #0 /home/jtrictez/public_html/admin/ninja/vendor/laravel/framework/src/Illuminate/Container/Container.php(959): ReflectionClass->__construct(‘config’) #1 /home/jtrictez/public_html/admin/ninja/vendor/laravel/framework/src/Illuminate/Container/Container.php(832): Illuminate\Container\Container->build(‘config’) #2 /home/jtrictez/public_html/admin/ninja/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(1078): Illuminate\Container\Container->resolve(‘config’, Array, true) #3 /home/jtrictez/public_html/admin/ninja/vendor/laravel/framework/src/Illuminate/Container/Container.php(763): Illuminate\Foundation\Application->resolve(‘config’, Array) #4 /home/jtrictez/public_html/admin/ninja/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(1058): Illuminate\Container\Container->make(‘config’, Array) #5 /home/jtrictez/public_html/admin/ninja/vendor/laravel/framework/src/Illuminate/Foundation/helpers.php(124): Illuminate\Foundation\Application->make(‘config’, Array) #6 /home/jtrictez/public_html/admin/ninja/vendor/laravel/framework/src/Illuminate/Foundation/helpers.php(279): app(‘config’) #7 /home/jtrictez/public_html/admin/ninja/app/Utils/Ninja.php(32): config(‘ninja.environme…’) #8 /home/jtrictez/public_html/admin/ninja/app/Exceptions/Handler.php(106): App\Utils\Ninja::isHosted() #9 /home/jtrictez/public_html/admin/ninja/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(563): App\Exceptions\Handler->report(Object(Error)) #10 /home/jtrictez/public_html/admin/ninja/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(147): Illuminate\Foundation\Http\Kernel->reportException(Object(Error)) #11 /home/jtrictez/public_html/admin/ninja/public/index.php(56): Illuminate\Foundation\Http\Kernel->handle(Object(Illuminate\Http\Request)) #12 {main} Next Illuminate\Contracts\Container\BindingResolutionException: Target class [config] does not exist. in /home/jtrictez/public_html/admin/ninja/vendor/laravel/framework/src/Illuminate/Container/Container.php:961 Stack trace: #0 /home/jtrictez/public_html/admin/ninja/vendor/laravel/framework/src/Illuminate/Container/Container.php(832): Illuminate\Container\Container->build(‘config’) #1 /home/jtrictez/public_html/admin/ninja/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(1078): Illuminate\Container\Container->resolve(‘config’, Array, true) #2 /home/jtrictez/public_html/admin/ninja/vendor/laravel/framework/src/Illuminate/Container/Container.php(763): Illuminate\Foundation\Application->resolve(‘config’, Array) #3 /home/jtrictez/public_html/admin/ninja/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(1058): Illuminate\Container\Container->make(‘config’, Array) #4 /home/jtrictez/public_html/admin/ninja/vendor/laravel/framework/src/Illuminate/Foundation/helpers.php(124): Illuminate\Foundation\Application->make(‘config’, Array) #5 /home/jtrictez/public_html/admin/ninja/vendor/laravel/framework/src/Illuminate/Foundation/helpers.php(279): app(‘config’) #6 /home/jtrictez/public_html/admin/ninja/app/Utils/Ninja.php(32): config(‘ninja.environme…’) #7 /home/jtrictez/public_html/admin/ninja/app/Exceptions/Handler.php(106): App\Utils\Ninja::isHosted() #8 /home/jtrictez/public_html/admin/ninja/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(563): App\Exceptions\Handler->report(Object(Error)) #9 /home/jtrictez/public_html/admin/ninja/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(147): Illuminate\Foundation\Http\Kernel->reportException(Object(Error)) #10 /home/jtrictez/public_html/admin/ninja/public/index.php(56): Illuminate\Foundation\Http\Kernel->handle(Object(Illuminate\Http\Request)) #11 {main} thrown in /home/jtrictez/public_html/admin/ninja/vendor/laravel/framework/src/Illuminate/Container/Container.php on line 961

What could be the issue and how do I resolve it ?
I was previously on 5.11.17 and the issue started, I upgraded to 5.11.72 and the issue still exists.

Thank you

Hi,

I’m not sure, in case it’s helpful here’s what ChatGPT suggests:

This Laravel error in Invoice Ninja — Fatal error: Uncaught ReflectionException: Class "config" does not exist — typically means Laravel’s service container is failing to resolve the config service, which is a core part of the framework. This shouldn’t happen under normal circumstances and usually points to one of the following issues:


:wrench: Most Common Causes & Fixes

:white_check_mark: 1. Corrupted or missing bootstrap/cache files

Laravel caches configuration and services here. If something goes wrong during deployment or file copying, this can break autoloading or service resolution.

Fix:

rm -rf bootstrap/cache/*.php
php artisan config:clear
php artisan cache:clear

:white_check_mark: 2. Composer autoload not properly generated

If the vendor folder is incomplete or corrupted (especially if the app was uploaded via FTP), dependencies might not be loaded properly.

Fix:

composer install --no-dev --optimize-autoloader

(If you’re on shared hosting, run it locally and upload the vendor folder fresh.)

:white_check_mark: 3. Missing or malformed config files

If the config folder or a config file like config/app.php is missing or malformed (e.g. syntax error), Laravel may be unable to resolve the config service.

Check:

  • Is config/app.php present?
  • Are there any PHP syntax errors?
  • Run:
php -l config/app.php

:white_check_mark: 4. Wrong Laravel version mismatch

If your Laravel vendor/ folder doesn’t match the Laravel version required by Invoice Ninja, this type of error can happen. For example, Laravel 8 vs 9 conflicts.

Fix:
Check composer.json and ensure the Laravel version matches the one supported by Invoice Ninja (for example: Laravel 9.x for Invoice Ninja v5.5+). Then re-run composer install.


:test_tube: Diagnosis Tip

Try this in tinker or a small routes/web.php test:

Route::get('/test', function () {
    return app('config')->get('app.name');
});

If that fails, it confirms the config service isn’t binding — likely a bootstrap, cache, or vendor issue.


Would you like help confirming the Laravel version or commands for your specific hosting setup (like shared hosting without terminal access)?

It seems that I don’t get that error anymore, but I am getting this when checking the network tab


Checking the laravel.log, i found this when I was in 5.11.72

Base table or view not found: 1146 Table 'jtrictez_ninj348.locations' doesn't exist

I then downloaded 5.11.17 again and it worked after a refresh.

It looks like the new database table doesn’t exist, it should help to run php artisan migrate