Set the application environment.

@param string $environment

@return $this
505476
public function setEnvironment($environment = '')
    {
        // Set the application environment
        $environment = ($environment ?: strtolower(getenv('APPLICATION_ENV')));
        $environment = ($environment ?: 'default');

        // Set the application environment
        $this->set('env', $environment);

        return $this;
    }
470015
public static function init($path, $environment = null)
    {
        if (!static::$instance)
            static::$instance = new Config($path, $environment);
        else {
            static::$instance->path = $path;
            static::$instance->environment = $environment;
            static::$instance->container = array();
        }

        return static::$instance;
    }
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;
    }
62761
public function setEnvironment($env)
    {
        Assert::oneOf($env, Environment::all(), 'The environment must be one of: %2$s. Got: %s');

        $this->env = $env;
    }
802100
private function setEnvironment($env) {
    if (isset($this->environments[$env])) {
      $this->loadEnvironment($env);
      return TRUE;
    }
    else {
      return FALSE;
    }
  }
887091
public static function setEnvironment($environment) {
        if (!empty($environment)) {
            foreach (array_values(static::$registeredInstances) as $instance) {
                $instance->setEnvironment($environment);
            }
            static::$ENVIRONMENT = $environment;
        } 
        
    }
416969
public function setEnvironment($env)
    {
        if ($this->started) {
            throw new LogicException('Puli is already started');
        }

        Assert::oneOf($env, Environment::all(), 'The environment must be one of: %2$s. Got: %s');

        $this->env = $env;
    }
49843
public function setEnvironmentDir($environmentDir) {
		if($environmentDir[0] != "/") $environmentDir = BASE_PATH . '/' . $environmentDir;
		$this->environmentDir = realpath($environmentDir) ?: $environmentDir;
	}
727126
public function env($env, $value = null)
    {
        if (! is_array($env)) {
            $env = [$env => $value];
        }

        foreach ($env as $key => $value) {
            $this->env[$key] = $value;
        }

        return $this;
    }
964364
public function setEnvironmentEncoding($encoding)
    {
        if (is_string($encoding)) {
            if (in_array($encoding, mb_list_encodings())) {
                $this->environmentEncoding = $encoding;
            } else {
                throw new \InvalidArgumentException(
                    "Invalid value '" . $encoding . "' for argument 'encoding' given. Encoding not supported."
                );
            }
        } else {
            throw new \InvalidArgumentException(
                "Invalid type '" . gettype($encoding). "' for argument 'encoding' given."
            );
        }

        return $this;
    }
648143
static function setCurrentEnvironment($environment)
    {
        if ( is_string($environment) && !class_exists($environment) )
            return static::setAlias($environment, static::CURRENT_NAME);
 

        static::register($environment, static::CURRENT_NAME);
    }
663338
public function init()
    {
        if (!defined('APPLICATION_PATH')) {
            throw new ArchException('Please define the APPLICATION_PATH constant');
        }
        if (!defined('APPLICATION_ENV')) {
            $env = getenv('APPLICATION_ENV');
            if ($env && !in_array($env, [self::ENV_DEV, self::ENV_STG, self::ENV_DEM, self::ENV_PRD])) {
                throw new ArchException('Execution environment "' . $env . '" is not correct. '
                            . 'Please choose one of theses : ' . self::ENV_DEV . ', ' . self::ENV_STG . ', ' 
                            . self::ENV_DEM . ' or ' . self::ENV_PRD);
            }
            define('APPLICATION_ENV', $env ?: self::ENV_PRD);
        }
        
        return $this;
    }
1324772
public static function determineAuthorization(Environment $environment)
    {
        $authorization = $environment->get('HTTP_AUTHORIZATION');
        if (!empty($authorization) || !is_callable('getallheaders')) {
            return $environment;
        }

        $headers = getallheaders();
        if (!is_array($headers)) {
            return $environment;
        }

        $headers = array_change_key_case($headers, CASE_LOWER);
        if (isset($headers['authorization'])) {
            $environment->set('HTTP_AUTHORIZATION', $headers['authorization']);
        }

        return $environment;
    }
310097
public function getEnvironment()
    {
        if ($this->environment == null) {
            $this->setEnvironment($this->getRevision()->getEnvironment());
        }
        return $this->environment;
    }
541969
public function init($environment = 'production'): void
    {
        $this->environment = $environment;

        try {
            // initial default helper path
            $this->addHelperPath(__DIR__ . '/Helper/');

            // init Config
            $this->initConfig();

            // first log message
            Logger::info('app:init');

            // init Session, start inside class (if needed)
            Session::getInstance();

            // init Messages
            Messages::getInstance();

            // init Request
            $this->initRequest();

            // init Response
            $this->initResponse();

            // init Translator
            $this->initTranslator();

            // init Router
            $this->initRouter();
        } catch (\Exception $e) {
            throw new ApplicationException("Application can't be loaded: " . $e->getMessage());
        }
    }
169090
public function create(Environment $environment)
    {
        $uri         = (new UriFactory())->create($environment);
        $uploadFiles = (new FilesFactory())->create($environment);
        $headers     = (new HeadersFactory())->create($environment);

        $cookies       = $environment->getCookies();
        $requestMethod = $environment->getRequestMethod();
        $bodyStream    = new Stream($environment->getBody());
        $protocol      = $environment->getProtocolVersion();

        $serverVariables = $environment->getServer();

        $serverRequest = new ServerRequest(
            $requestMethod,
            $uri,
            $bodyStream,
            $headers,
            $serverVariables,
            $cookies,
            $uploadFiles,
            $protocol
        );

        // php://input is not available with enctype="multipart/form-data".
        if ($this->usePostAsParsed($requestMethod, $serverRequest)) {
            $serverRequest = $serverRequest->withParsedBody($environment->getPost());
        }

        return $serverRequest;
    }
1055016
public function setEnvironment($env = self::ENV_PRODUCTION)
    {
        if ($env != self::ENV_DEVELOPMENT && $env != self::ENV_PRODUCTION) {
            throw new RestException('Unknown environment "' . $env . '".');
        }

        $this->environment = $env;
    }