Fix Reflection Exception Class Env Does Not Exist

Ariel Mejia

November 12th, 2020 - 1 min read

The problem:

Using Laravel/Telescope while running your tests with

php artisan test

Then console throws this exception

ReflectionException: Class env does not exist

Below it says that something in test environment fails with Telescope, I didn't change any code base or environment so...

Solution

  • Step 1

Disable telescope for tests on your PHPUnit.xml add:

<env name="TELESCOPE_ENABLED" value="false"/>
  • Step 2

Then go to the terminal and execute:

php artisan clear
php artisan config:clear

Credits

I get the solution from two sites:

I only facilitate the information in this platform because I had a few hours searching for a solution, and it makes easier to search for anyone in the future.

Thanks for reading!


Ariel Mejia Illustration

Ariel Mejia

Laravel Senior Developer

Engineer with 7+ years of experience working in backend & frontend technologies
Open Source Maintainer of packages for Laravel community.

Stay up with Laravel

Sign up & get tips and tricks

You'll get monthly updates regarding my most recent articles and products.