src/Configuration/EnvConfiguration.php
private function detectEnvFile()
    {
        $env = DIRECTORY_SEPARATOR . '.env';
        $dir = dirname(dirname(__DIR__));

        do {
            if (is_file($dir . $env)) {
                return $dir . $env;
            }
            $dir = dirname($dir);
        } while (is_readable($dir) && dirname($dir) !== $dir);

        throw EnvException::detectionFailed();
    }
private function detectEnvFile()
    {
        $env = DIRECTORY_SEPARATOR . '.env';
        $dir = dirname(dirname(__DIR__));

        do {
            if (is_file($dir . $env)) {
                return $dir . $env;
            }
            $dir = dirname($dir);
        } while (is_readable($dir) && dirname($dir) !== $dir);

        throw EnvException::detectionFailed();
    }
Find a .env file by traversing up the filesystem

@return string

@throws EnvException If no file is found