Create the '.env' from '.env.example'.

@param $reset
421040
public function createEnvironmentFile($reset)
    {
        $path = app()->environmentFilePath();
        $shouldCreateFile = ! file_exists($path) || $reset;

        if ($shouldCreateFile) {
            $description = 'Creating environment file';
            $this->output->write('<comment>' . $description . '...</comment> ');
            copy(base_path('.env.example'), $path);
            $this->output->write('Done!' . PHP_EOL);

            $this->reloadEnvironment();
        }
    }
92935
public static function env(string $key, $default = null)
    {
        self::initialize();
        $value = getenv($key);
        if ($value === false) {
            return $default;
        }
        return $value;
    }
802100
private function setEnvironment($env) {
    if (isset($this->environments[$env])) {
      $this->loadEnvironment($env);
      return TRUE;
    }
    else {
      return FALSE;
    }
  }
1018159
public function create(Environment $environment)
    {
        $scheme = $environment->getRequestScheme();
        $host   = $environment->getHost();
        $port   = $environment->getPort();
        $query  = $environment->getQueryString();
        $user   = $environment->getAuthUser();
        $pass   = $environment->getAuthPassword();

        // parse_url() requires a full URL - but only URL path is need it here.
        $path = parse_url('http://example.com' . $environment->getRequestUri(), PHP_URL_PATH);
        if ($path === false) {
            throw new InvalidArgumentException('Uri path must be a string');
        }

        return new Uri($scheme, $host, $port, $path, $query, '', $user, $pass);
    }
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);
    }
935143
public function bootstrap()
    {
        $app = Zilf::$app;
        $this->checkForSpecificEnvironmentFile($app);

        try {
            (new Dotenv($app->environmentPath(), $app->environmentFile()))->load();
        } catch (InvalidPathException $e) {
            //
        } catch (InvalidFileException $e) {
            die('The environment file is invalid: ' . $e->getMessage());
        }
    }
1176775
function reset() {
        foreach ($this->vars as $key=>$val) {
            unset($this->env[$key]);
        }
        $this->vars = array();
    }
435183
private function prepareEnvironment()
    {
        $filesystem = $this->make(Filesystem::class);


        if ($filesystem instanceof Filesystem) {
            if ($filesystem->exists($path = $this->getEnvironmentPath())) {
                $env = $filesystem->get($path);


                array_map(
                    function ($env) {

                        if ($env !== '' && $env !== null) {
                            putenv($env);
                        }
                    },
                    explode("\n", $env)
                );

                $this->environments = count($_ENV) ? $_ENV : isset($_SERVER['ENV']) ? $_SERVER['ENV'] : [];
            }
        }

    }
1009773
public static function init($locale, $environment, $version)
    {
        $envFilename = Registry::get('applicationPath') . '/.env';
        if (file_exists($envFilename)) {
            $env = Ini::parse($envFilename, true, $locale . '-' . $environment . '-' . $version, 'common', false);
            $env = self::mergeEnvVariables($env);
        } else {
            $env = new \StdClass();
        }
        self::$data = Ini::bindArrayToObject($env);
    }
666761
public function createBaseEm($env)
    {
        if($env == 'dev')
        {
            $devEnv = true;
        }
        else
        {
            $devEnv = false;
        }

        AnnotationRegistry::registerFile($this->paths['root'] . '/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php');
        AnnotationRegistry::registerAutoloadNamespace('Symfony\Component\Validator\Constraints', $this->paths['root'] . '/vendor/symfony/validator');

        $reader = new FileCacheReader(new AnnotationReader(), $this->paths['app'] . '/cache/doctrine/annotations', $debug = true);

        $driverImpl = new \Doctrine\ORM\Mapping\Driver\AnnotationDriver($reader, array($this->paths['src']."/Model"));
        $config = Setup::createAnnotationMetadataConfiguration(array($this->paths['src']."/Model"), $devEnv);
        $config->setMetadataDriverImpl($driverImpl);
        $conn = $this->getParams();

        $this->em = EntityManager::create($conn, $config);
    }
1272275
protected function setDefaultEnvironment() {
		#Using _ENV_ and $_SERVER only as the last chance to guess the environment.
		#User can and should set the environment through constructor or setEnv($env).

		if(isset($this->params['env']))
			return;
		if(defined('_ENV_'))
			$this->params['env'] = _ENV_;
		elseif(file_exists($file = $this->params['root'].'/storage/environment'))
			$this->params['env'] = trim(file_get_contents($file));
		elseif($this->get('consoleMode')) {
			foreach($_SERVER['argv'] as $k=>$v) {
				if($v === '--env' && isset($_SERVER['argv'][$k+1])) {
					$this->params['env'] = $_SERVER['argv'][$k+1];
					return;
				}
			}
			$this->params['env'] = 'dev';
		}
		elseif(php_sapi_name() === 'cli' || (isset($_SERVER['HTTP_HOST']) && ($_SERVER['HTTP_HOST'] == '127.0.0.1' || $_SERVER['HTTP_HOST'] == 'localhost')))
			$this->params['env'] = 'dev';
		else
			$this->params['env'] = 'prod';
	}
13608
protected function setEnv(
        /*# string */ $key,
        /*# string */ $val,
        /*# bool */ $overload
    ) {
        if ($overload || false === getenv($key)) {
            // set env
            putenv("$key=$val");

            // also populate $_ENV
            $_ENV[$key] = $val;
        }
    }
774042
public function getEnv($key = null, $default = null) {
        if (null === $key) {
            return $this->ENV;
        }

        return (isset($this->ENV[$key])) ? $this->ENV[$key] : $default;
    }
256445
protected function loadEnv()
    {
        try {
            $this->dotenv->load();
            $this->dotenv->required($this->required);
        } catch (\InvalidArgumentException $e) {
            // Assuming env data is set by server
        }
    }
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();
        }
    }
677047
public function setEnv(string $name, ?string $value = null): ProcessBuilder
    {
        $this->environment[$name] = $value;

        return $this;
    }
539269
public function setEnv($env = null)
    {
        if (in_array($env, \WebServCo\Framework\Environment::getOptions())) {
            $this->env = $env;
        } else {
            $this->env = \WebServCo\Framework\Environment::ENV_DEV;
        }

        return true;
    }