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

jove's avatar
Level 7

Class config does not exist in

$ php artisan
PHP Fatal error:  Uncaught ReflectionException: Class config does not exist in /<project>/vendor/laravel/framework/src/Illuminate/Container/Container.php:767
Stack trace:
#0 /<project>/vendor/laravel/framework/src/Illuminate/Container/Container.php(767): ReflectionClass->__construct('config')
#1 /<project>/vendor/laravel/framework/src/Illuminate/Container/Container.php(646): Illuminate\Container\Container->build('config')
#2 /<project>/vendor/laravel/framework/src/Illuminate/Container/Container.php(601): Illuminate\Container\Container->resolve('config', Array)
#3 /<project>/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(740): Illuminate\Container\Container->make('config', Array)
#4 /<project>/vendor/laravel/framework/src/Illuminate/Container/Container.php(1210): Illuminate\Foundation\Application->make('config')
#5 /<project>/vendor/laravel/framework/src/Illuminat in /<project>/vendor/laravel/framework/src/Illuminate/Container/Container.php on line 767

I was trying to make a function that could edit the .env file. got it to work, but after artisan config:clear config:cache I get this.

0 likes
9 replies
samuelbie's avatar

For For those still facing the same problem, what I solved for me was: remove all contents of the bootstrap / cache folder, and run the composer dump command

2 likes
Zinnie's avatar

@samuelbie Thanks.

Also for those still having this issue, delete the vendor directory, then run the composer install command.

1 like
lovol2's avatar

Thank you Samuelbie. Total saviour...

for others.

Using FreeScout (laravel 5.5) Error: AH01071: Got error 'PHP message: PHP Fatal error: Uncaught ReflectionException: Class config does not exist in laravel/framework/src/Illuminate/Container/Container.php:752

Do

Delete all the files in bootstrap/cache folder.

try to load page again and it works.

Thanks again Smauelbie, I would never have figured this out without your comment saying what to do. I didn't do the dump thing, didn't know how!

1 like
digitlimit's avatar

This issue can also be caused by a poorly indented or missing .env file. Ensure your .env file exists and properly set

darkestmon's avatar

On my case, I fixed this by adding an empty tearDown function in my test script

public function tearDown(): void
{
    // do not remove this function
}
2 likes
Stacky's avatar

@darkestmon Similar to your fix. I remove an empty Setup function in my test script! 👍

Please or to participate in this conversation.