Question: Fatal error: Class 'Dotenv\Dotenv' not found in .../Bootstrap/DetectEnvironment.php on line 24


Fatal error: Class 'Dotenv\Dotenv' not found in .../Bootstrap/DetectEnvironment.php on line 24

Answers 0
Added at 2017-01-02 05:01

Not sure why I am getting this message:

Fatal error: Uncaught Symfony\Component\Debug\Exception\FatalThrowableError: Class 'Dotenv\Dotenv' not found in /home/vagrant/devbox/devbox.local/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/DetectEnvironment.php on line 24

Below is the DetectEnvironment.php code:


namespace Illuminate\Foundation\Bootstrap;

use Dotenv\Dotenv;
use Dotenv\Exception\InvalidPathException;
use Symfony\Component\Console\Input\ArgvInput;
use Illuminate\Contracts\Foundation\Application;

class DetectEnvironment
     * Bootstrap the given application.
     * @param  \Illuminate\Contracts\Foundation\Application  $app
     * @return void
    public function bootstrap(Application $app)
        if (! $app->configurationIsCached()) {

            try {
                (new Dotenv($app->environmentPath(), $app->environmentFile()))->load();
            } catch (InvalidPathException $e) {

My project had been working correctly until I restarted the computer and server. Whenever I go to the site or run a composer or artisan command I get the error above.

I have tried various solutions that I have found but none have worked. This includes:

  • specifically adding vlucas/phpdotenv to the composer file (it already existed in the vendor file structure, but added it to make sure)
  • running composer update and composer dumpautoload
  • creating a new .env file

Creating a new laravel project works, but I really don't want to have to do that (there must be an easy explanation/fix for this).

Similar issues as listed in, but neither have answers that work for me:

I am using the latest Laravel version and running it on Homestead.

Any guidance is greatly appreciated!

Answers to

Fatal error: Class &#39;Dotenv\Dotenv&#39; not found in .../Bootstrap/DetectEnvironment.php on line 24

Source Show
◀ Wstecz