Create a Dotenv instance.

@return \Dotenv\Dotenv
559987
protected function createDotenv()
    {
        return Dotenv::create(
            $this->filePath,
            $this->fileName,
            new DotenvFactory([new EnvConstAdapter, new PutenvAdapter, new ServerConstAdapter])
        );
    }
142242
public function bootstrap()
    {
        if (! class_exists(DotenvFactory::class)) {
            $this->writeErrorAndDie([
                'Unable to load the environment file!',
                'Please install "vlucas/phpdotenv:^3.3".',
            ]);
        }

        try {
            $this->createDotenv()->safeLoad();
        } catch (InvalidFileException $e) {
            $this->writeErrorAndDie([
                'The environment file is invalid!',
                $e->getMessage(),
            ]);
        }
    }
113393
public function makeFromEnvironment()
    {
        $env = new EnvUtils();

        // Check that we have all variables we need
        if (!$env->hasBearerKey()) {
            throw new Exception(
                'TUTUM_AUTH is not set. Unable to create from environment'
            );
        }

        $client = new Client('', '');
        $client->setBearerKey($env->getBearerKey());

        return $client;
    }
647800
public function rawOnEnvironment()
    {
        $environments = array_flatten(func_get_args());

        if (in_array($this->appEnvironment, $environments))
        {
            return $this->raw();
        }

        return $this;
    }
531752
protected function loadEnv()
    {
        if (defined('ENV_DIR') && file_exists(ENV_DIR)) {
            if (defined('ENV_FILE') && file_exists(ENV_FILE)) {
                $dotenv = new \Dotenv\Dotenv(ENV_DIR, ENV_FILE);
            } else {
                $dotenv = new \Dotenv\Dotenv(ENV_DIR);
            }
            $dotenv->load();
        }
    }
974190
public function instance() {
		if ( ! isset( self::$environment ) ) {
			self::$environment = $this->boot();
		}

		return self::$environment;
	}
131279
protected function envFileToUseForDefaults()
    {
        $file = config('setup.dot_env.default_file');

        if ($this->envFileExist() &&
            $this->command->confirm('Existing .env file was found. Use it for defaults?', true)
        )
        {
            $file = '.env';
        }

        return $file;
    }
332247
public function environment($env = null)
    {
        if ($env !== null) {
            // Windows nodejs needs these environment variables.
            $winenv = $this->_getenv(array('SystemDrive', 'SystemRoot'));
            $this->_env = array_merge($winenv, $env);
            return $this;
        }
        return $this->_env;
    }
851170
public static function createFromGlobal()
    {
        $instance = new self('');

        //~ Set scheme
        if (isset($_SERVER['HTTPS'])) {
            $instance->setScheme($_SERVER['HTTPS'] == 'on' ? 'https' : 'http');
        }

        //~ Set host
        if (isset($_SERVER['HTTP_HOST'])) {
            $instance->setHost($_SERVER['HTTP_HOST']);
        } elseif (isset($_SERVER['SERVER_NAME'])) {
            $instance->setHost($_SERVER['SERVER_NAME']);
        }

        //~ Set port
        if (isset($_SERVER['SERVER_PORT'])) {
            $instance->setPort($_SERVER['SERVER_PORT']);
        }

        //~ Set path
        if (isset($_SERVER['REQUEST_URI'])) {
            $instance->setPath(current(explode('?', $_SERVER['REQUEST_URI'])));
        }

        //~ Set query string
        if (isset($_SERVER['QUERY_STRING'])) {
            $instance->setQuery($_SERVER['QUERY_STRING']);
        }

        return $instance;
    }
605040
private function getEnvironment()
    {
        $paths         = $this->config->paths;
        $paths['root'] = $this->root;
        return new \Taniko\Saori\Generator\Environment(
            $this->getMaker(),
            $this->getTwigEnv("{$this->theme_dir}/twig"),
            $paths
        );
    }
1247398
public static function env()
    {
        return function () {
            // Use credentials from environment variables, if available
            $key = getenv(self::ENV_KEY);
            $secret = getenv(self::ENV_SECRET);
            if ($key && $secret) {
                return Promise\promise_for(
                    new Credentials($key, $secret, getenv(self::ENV_SESSION) ?: NULL)
                );
            }

            return self::reject('Could not find environment variable '
                . 'credentials in ' . self::ENV_KEY . '/' . self::ENV_SECRET);
        };
    }
669398
protected function initEnvironment()
    {
        $path = getcwd();
        if (!is_file("$path/.env")) {
            return;
        }
        $dotenv = new \Dotenv\Dotenv($path);
        if ($this->dotEnvOverload) {
            $dotenv->overload();
        } else {
            $dotenv->load();
        }
    }
319606
public function bootstrap(Container $app)
    {
        $this->app = $app;
        
        $this->app->singleton('env', function ($app) {
            return new Dotenv(base_path(), $this->getEnvFileName());
        });
        
        $env = $this->app->make('env');
        
        $env->overload();
        $env->required([
            'DB_NAME',
            'DB_USER',
            'DB_PASS',
            'DB_HOST',
        ]);
    }
217328
public static function create(
        string $projectRoot, $default = self::ENV_PRODUCTION, array $allowed = []
    ): EnvironmentInterface
    {
        if (! $allowed) {
            $allowed = [
                self::ENV_PRODUCTION,
                self::ENV_STAGING,
                self::ENV_TESTING,
                self::ENV_DEVELOPMENT,
            ];
        }

        $projectRoot = realpath($projectRoot);

        $filename = $projectRoot . '/.environment';
        if (! $projectRoot || ! file_exists($filename)) {
            return new static($default, $projectRoot);
        }

        // get the environment name
        $name = file_get_contents($filename);

        if (! in_array($name, $allowed)) {
            throw new UnknownEnvironmentException(
                'Unknown environment "' . $name . '". Either add to the allowed list or provide one of: '
                . join(', ', $allowed)
            );
        }

        return new static($name, $projectRoot);
    }
439314
public function createTarFileSet()
    {
        $this->fileset = new TarFileSet();
        $this->filesets[] = $this->fileset;

        return $this->fileset;
    }
625836
public function overloadEnvironment()
    {
        if (is_file($this->getFullEnvFilePath())) {
            $env = new DotEnv($this->basePath, $this->getEnvFile());
            $env->overLoad();
        }
    }
1343825
protected function registerEnv()
    {
        $file_env = $this->basePath('.env');

        $env = new Dotenv($this->basePath(), '.env');
        if (file_exists($file_env)) {
            $env->load();
        }
    }