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();
    }