DEV Community

Ariel Mejia
Ariel Mejia

Posted on • Updated on

Solve "ReflectionException: Class env does not exist"

The problem:

Run your tests with:

  • old way:
vendor/bin/phpunit
Enter fullscreen mode Exit fullscreen mode
  • new way:
php artisan test
Enter fullscreen mode Exit fullscreen mode
  • Or using the PHPStorm UI.

Then in console throws this error:

ReflectionException: Class env does not exist
Enter fullscreen mode Exit fullscreen mode

Below it says that something in test environment fails with Telescope, I didnt change any code base or environment so... this problem is always related with cache:

Solution

  • Step 1

Disable telescope for tests on your PHPUnit.xml add:

<env name="TELESCOPE_ENABLED" value="false"/>
Enter fullscreen mode Exit fullscreen mode
  • Step 2

Then go to the terminal and execute:

php artisan clear
php artisan config:clear
Enter fullscreen mode Exit fullscreen mode

Note

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 with a descriptive title it would be easy to search for anyone in the future.

Thanks for reading!

Top comments (2)

Collapse
 
oldu67 profile image
recai

I solved. Thanks Ariel:)

Collapse
 
arielmejiadev profile image
Ariel Mejia

You are welcome!