The Mysterious Unsolvable Laravel Error

Laravel devs, this one’s for you. Are you familiar with this error?

Fatal error: Uncaught exception ‘ReflectionException’ with message ‘Class log does not exist’ in /home/myapp/laravel/vendor/laravel/framework/src/Illuminate/Container/Container.php

If you’re not, then you’re lucky. But if you are, I know your struggle. This error occurs pretty high in the stack trace and is an absolute pain to resolve, particularly because the error dump doesn’t actually tell you what caused the error.

The solution, however, is simple:

##You used a helper function in a configuration file.

From what I can tell, in Laravel, configuration files are run before helper files. So, you unfortunately won’t be able to use trans() or getenv() to dynamically change settings based on locales.

Thanks for reading; if you need any more help, I’ll be here!