Create instance of ServerRequest object from instance of Environment object

@param Environment $environment environment data

@return ServerRequest Instance of ServerRequest object
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;
    }
1251509
public function setEnvironment($environment)
    {
        $this->environment = null === $environment ? '' : $environment;
        $this->flushAll();

        return $this;
    }
1071833
protected function setEnvironment($environment)
    {
        $subdirs = [''];
        if (null !== $environment) {
            $subdirs = array_merge($subdirs, preg_split('/[\/\\\]/',
                trim($environment, '/\\'), 0, \PREG_SPLIT_NO_EMPTY));
        }
        $this->sub_dirs = $subdirs;

        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;
    }
997899
public static function createFromEnvironment(\Slim\Environment $env) {
        if (isset($env['slim.files']) && is_array($env['slim.files'])) {
            return $env['slim.files'];
        } elseif (isset($_FILES)) {
            return static::parseUploadedFiles($_FILES);
        }

        return array();
    }
572288
public function createArgumentResolvers(Environment $environment)
    {
        $suite = $environment->getSuite();

        if (!$suite->hasSetting('services')) {
            return array();
        }

        $container = $this->createContainer($suite->getSetting('services'));
        $autowire = $suite->hasSetting('autowire') && $suite->getSetting('autowire');

        if ($environment instanceof ServiceContainerEnvironment) {
            $environment->setServiceContainer($container);
        }

        return $this->createResolvers($container, $autowire);
    }
1135264
public function buildApp(string $environmentName) : App
    {
        // create IoC container with middleware instances
        $middleware = new IoCContainerFromConfigArray($this->cfg->get('middleware'));

        // create IoC container with modules
        $modules = new IoCContainerFromConfigArray($this->cfg->get('modules'));

        // build and return app
        $app = new AppDefault($environmentName, $this->cfg, $modules, $middleware);
        return $app;
    }
1231862
protected function process(EnvironmentInterface $environment)
    {
        $inputProvider  = $environment->getInputProvider();
        $dataDefinition = $environment->getDataDefinition();

        $modelId = ModelId::fromSerialized($inputProvider->getParameter('id'));

        // Guard that we are in the preloaded environment. Otherwise checking the data definition could belong to
        // another model.
        $this->guardValidEnvironment($dataDefinition, $modelId);

        // Only edit mode is supported. Trigger an edit action.
        if ($dataDefinition->getBasicDefinition()->isEditOnlyMode()) {
            return $this->callAction($environment, 'edit');
        }

        // We want a redirect here if not deletable.
        $this->guardIsDeletable($environment, $modelId, true);
        $this->deepDelete($environment, $modelId);
        $this->delete($environment, $modelId);

        if ('delete' === $inputProvider->getParameter('mode')) {
            return null;
        }

        ViewHelpers::redirectHome($environment);

        return null;
    }
43816
public function setEnvironment($environment)
    {
        if (array_key_exists('environments', $this->configuration) && array_key_exists($environment, $this->configuration['environments'])) {
            $this->environment = $environment;
            return $this;
        }

        throw new RuntimeException(sprintf('The environment "%s" does not exists.', $environment), 100);
    }
120762
public static function createFromEnvironment(Environment $env)
    {
        // Scheme
        $isSecure = $env->get('HTTPS');
        $scheme = (empty($isSecure) || $isSecure === 'off') ? 'http' : 'https';

        // Authority: Username and password
        $username = $env->get('PHP_AUTH_USER', '');
        $password = $env->get('PHP_AUTH_PW', '');

        // Authority: Host and Port
        if ($env->has('HTTP_HOST')) {
            $host = $env->get('HTTP_HOST');
            // set a port default
            $port = null;
        } else {
            $host = $env->get('SERVER_NAME');
            // set a port default
            $port = (int)$env->get('SERVER_PORT', 80);
        }

        if (preg_match('/^(\[[a-fA-F0-9:.]+\])(:\d+)?\z/', $host, $matches)) {
            $host = $matches[1];

            if (isset($matches[2])) {
                $port = (int) substr($matches[2], 1);
            }
        } else {
            $pos = strpos($host, ':');
            if ($pos !== false) {
                $port = (int) substr($host, $pos + 1);
                $host = strstr($host, ':', true);
            }
        }

        // Path
        $requestScriptName = parse_url($env->get('SCRIPT_NAME'), PHP_URL_PATH);
        $requestScriptDir = dirname($requestScriptName);

        // parse_url() requires a full URL. As we don't extract the domain name or scheme,
        // we use a stand-in.
        $requestUri = parse_url('http://example.com' . $env->get('REQUEST_URI'), PHP_URL_PATH);

        $basePath = '';
        $virtualPath = $requestUri;
        if (stripos($requestUri, $requestScriptName) === 0) {
            $basePath = $requestScriptName;
        } elseif ($requestScriptDir !== '/' && stripos($requestUri, $requestScriptDir) === 0) {
            $basePath = $requestScriptDir;
        }

        if ($basePath) {
            $virtualPath = ltrim(substr($requestUri, strlen($basePath)), '/');
        }

        // Query string
        $queryString = $env->get('QUERY_STRING', '');
        if ($queryString === '') {
            $queryString = parse_url('http://example.com' . $env->get('REQUEST_URI'), PHP_URL_QUERY);
        }

        // Fragment
        $fragment = '';

        // Build Uri
        $uri = new static($scheme, $host, $port, $virtualPath, $queryString, $fragment, $username, $password);
        if ($basePath) {
            $uri = $uri->withBasePath($basePath);
        }

        return $uri;
    }
720982
public function setup(string $environment = null)
    {
        if (isset($this->initialized['setup'])) {
            return $this;
        }

        $this->initialized['setup'] = true;

        $this->measureTime('_setup', 'Site Setup', function () use ($environment) {
            // Force environment if passed to the method.
            if ($environment) {
                Setup::$environment = $environment;
            }

            $this['setup'];
            $this['streams'];
        });

        return $this;
    }
67533
public static function createFromEnvironment()
    {
        // Clean and update live global variables
        $variables = static::cleanEnvironment(Environment::getVariables());
        Environment::setVariables($variables); // Currently necessary for SSViewer, etc to work

        // Health-check prior to creating environment
        return static::createFromVariables($variables, @file_get_contents('php://input'));
    }
130357
protected function getRollbarHandler($environment)
    {
        $rollbarConfig = Arr::get($this->config, 'rollbar', []);
        return new RollbarHandler($rollbarConfig, $environment);
    }
1296119
private function extractParameters(SystemEnvironmentInterface $environment)
    {
        $server = $this->environment->getRequestHelper()->getServerParams();
        $params = array();
        parse_str(isset($server['QUERY_STRING']) ? $server['QUERY_STRING'] : '', $params);
        $body = $this->environment->getStdInput();
        $content_type = isset($server['CONTENT_TYPE']) ? $server['CONTENT_TYPE'] : '';
        if (strchr($content_type, ';') !== false) {
            list($content_type) = preg_split('/;/', $content_type, 2);
        }
        switch ($content_type) {
            case "application/json":
                $params = array_merge($params, $this->parseApplicationJson($body));
                break;

            case "application/x-www-form-urlencoded":
                $params = array_merge($params, $this->parseApplicationFormUrlEncoded($body));
                break;

            case "multipart/form-data":
                $params = array_merge($params, $this->parseMultipartFormdata($body));
                break;
        }
        $environment->getRequestHelper()->fillWithData($params);
    }
1162313
function createEnvironment()
    {
        $env = new Environment;

        $loadPaths = $this->loadPaths ?: array();

        foreach ($loadPaths as $path) {
            $env->appendPath(dirname($this->filename) . "/" . $path);
        }

        if (!$this->debug) {
            if ($jsCompressor = $this->jsCompressor) {
                $env->setJsCompressor($jsCompressor);
            }

            if ($cssCompressor = $this->cssCompressor) {
                $env->setCssCompressor($cssCompressor);
            }
        }

        return $env;
    }
702978
public function findByUrlAndEnvironment($url, $environment)
    {
        $queryBuilder = $this->createQueryBuilder('u')
            ->where('u.url = :url')
            ->andWhere('u.environment = :environment');

        $query = $queryBuilder->getQuery();
        $query->setParameter('url', $url);
        $query->setParameter('environment', $environment);

        try {
            return $query->getSingleResult();
        } catch (NoResultException $ex) {
            return;
        }
    }
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);
    }