Setup the browser environment.

@return void
193387
protected function setUpTheBrowserEnvironment()
    {
        Browser::$baseUrl = $this->baseUrl();

        $this->prepareDirectories();

        Browser::$userResolver = function () {
            return $this->user();
        };
    }
874023
public function setup(){
		if($this->hasOption('autoinit') && $this->options()->autoinit){
			if($this->hasOption('default')){
				$this->setValue($this->options()->default);
			}else{
				$this->setValue('now');
			}
		}
	}
1201989
public function setup_from_path() {
		$this->file = basename( $this->basefile );
		$dir        = dirname( $this->basefile );
		$this->slug = basename( $dir );
		$exts       = explode( '.', $this->basefile );
		$ext        = $exts[ count( $exts ) - 1 ];
		if ( 'css' === $ext ) {
			$this->type = 'theme';
		}
		if ( 'php' === $ext ) {
			$this->type = 'plugin';
		}
		$this->key = self::key_ready_name( $this->slug );
	}
1084921
public function setup() {
		// do parent
		parent::setup();
		if ( ! isset( $this->struct['screen'] ) ) {
			$this->struct['screen'] = ( $this->parent ? $this->parent->slug : null );
		}
	}
484500
public function setup() {
		parent::setup();

		if(!is_admin()) {
			return;
		}

		$this->client = StorageManager::storageInstance();
		if ($this->client && $this->client->enabled() && $this->client->supportsDirectUploads()) {
			$this->setupAdmin();
			$this->setupAdminAjax();
		}
	}
9635
protected function initEnvironment(): void
    {
        $envFile = $this->getRootRelatedPath($this->getEnvFileName());

        $this->assertFileIsReadable($envFile);

        self::$envIsSet = (bool)(new Dotenv($this->getRootDirectory(), $this->getEnvFileName()))->load();
    }
893807
public function initialize() : void
    {
        foreach (glob("{$this->cssDir}/*.css") as $file) {
            $filename = basename($file);
            $url = "{$this->cssUrl}/$filename";
            $content = file_get_contents($file);
            $comment = strstr($content, "*/", true);
            $comment = preg_replace(["#\/\*!#", "#\*#"], "", $comment);
            $comment = preg_replace("#@#", "<br>@", $comment);
            $first = strpos($comment, ".");
            $short = substr($comment, 0, $first + 1);
            $long = substr($comment, $first + 1);
            $this->styles[$url] = [
                "shortDescription" => $short,
                "longDescription" => $long,
            ];
        }

        foreach ($this->styles as $key => $value) {
            $isMinified = strstr($key, ".min.css", true);
            if ($isMinified) {
                unset($this->styles["$isMinified.css"]);
            }
        }
    }
1011362
public function init() {
		$this->set_configs();
		$this->set_enabled();
		$this->set_modules_css();
		$this->set_google_fonts();
		$this->set_modules_webfonts();
		$this->add_hooks();
	}
1204109
public function bootstrap()
    {

        // setup autoloader
        require SERVER_AUTOLOADER;

        // make the application available and register the class loaders
        $application = $this->application;
        $application->registerClassLoaders();

        // register the applications annotation registries
        $application->registerAnnotationRegistries();

        // add the application instance to the environment
        Environment::singleton()->setAttribute(EnvironmentKeys::APPLICATION, $application);

        // create s simulated request/session ID whereas session equals request ID
        Environment::singleton()->setAttribute(EnvironmentKeys::SESSION_ID, $sessionId = SessionUtils::generateRandomString());
        Environment::singleton()->setAttribute(EnvironmentKeys::REQUEST_ID, $sessionId);

        // try to load the profile logger
        if (isset($this->loggers[$profileLoggerKey = \AppserverIo\Logger\LoggerUtils::PROFILE])) {
            $this->profileLogger = $this->loggers[$profileLoggerKey];
            $this->profileLogger->appendThreadContext('timer-service-executor');
        }
    }
523384
private static function setup()
    {
        $files = ['Routes', 'Setup', 'Response'];
        $folder = static::$root.'Setup'.'/';

        self::call($files, $folder);

        $files = ['Database', 'Panel', 'Security', 'Maintenance', 'Loggin', 'Translator', 'App', 'Robots'];
        $folder = static::$root.'Setup/Documentations'.'/';

        self::call($files, $folder);

        $files = ['AppSetupException'];
        $folder = static::$root.'Setup/Exceptions'.'/';

        self::call($files, $folder);
    }
892114
public function init()
    {
        $grav = Grav::instance();

        /** @var Config $config */
        $config = $grav['config'];

        /** @var Language $language */
        $language = $grav['language'];

        // add the port to the base for non-standard ports
        if ($this->port !== null && $config->get('system.reverse_proxy_setup') === false) {
            $this->base .= ':' . (string)$this->port;
        }

        // Handle custom base
        $custom_base = rtrim($grav['config']->get('system.custom_base_url'), '/');

        if ($custom_base) {
            $custom_parts = parse_url($custom_base);
            $orig_root_path = $this->root_path;
            $this->root_path = isset($custom_parts['path']) ? rtrim($custom_parts['path'], '/') : '';
            if (isset($custom_parts['scheme'])) {
                $this->base = $custom_parts['scheme'] . '://' . $custom_parts['host'];
                $this->root = $custom_base;
            } else {
                $this->root = $this->base . $this->root_path;
            }
            $this->uri = Utils::replaceFirstOccurrence($orig_root_path, $this->root_path, $this->uri);
        } else {
            $this->root = $this->base . $this->root_path;
        }

        $this->url = $this->base . $this->uri;

        $uri = str_replace(static::filterPath($this->root), '', $this->url);

        // remove the setup.php based base if set:
        $setup_base = $grav['pages']->base();
        if ($setup_base) {
            $uri = preg_replace('|^' . preg_quote($setup_base, '|') . '|', '', $uri);
        }

        // process params
        $uri = $this->processParams($uri, $config->get('system.param_sep'));

        // set active language
        $uri = $language->setActiveFromUri($uri);

        // split the URL and params
        $bits = parse_url($uri);

        //process fragment
        if (isset($bits['fragment'])) {
            $this->fragment = $bits['fragment'];
        }

        // Get the path. If there's no path, make sure pathinfo() still returns dirname variable
        $path = $bits['path'] ?? '/';

        // remove the extension if there is one set
        $parts = pathinfo($path);

        // set the original basename
        $this->basename = $parts['basename'];

        // set the extension
        if (isset($parts['extension'])) {
            $this->extension = $parts['extension'];
        }

        // Strip the file extension for valid page types
        if ($this->isValidExtension($this->extension)) {
            $path = Utils::replaceLastOccurrence(".{$this->extension}", '', $path);
        }

        // set the new url
        $this->url = $this->root . $path;
        $this->path = static::cleanPath($path);
        $this->content_path = trim(str_replace($this->base, '', $this->path), '/');
        if ($this->content_path !== '') {
            $this->paths = explode('/', $this->content_path);
        }

        // Set some Grav stuff
        $grav['base_url_absolute'] = $config->get('system.custom_base_url') ?: $this->rootUrl(true);
        $grav['base_url_relative'] = $this->rootUrl(false);
        $grav['base_url'] = $config->get('system.absolute_urls') ? $grav['base_url_absolute'] : $grav['base_url_relative'];

        RouteFactory::setRoot($this->root_path);
        RouteFactory::setLanguage($language->getLanguageURLPrefix());
    }
401256
public function setupFilesystem()
    {
        $config = $this['config'];

        if (!is_dir($config->get('concrete.cache.directory'))) {
            @mkdir($config->get('concrete.cache.directory'), $config->get('concrete.filesystem.permissions.directory'));
            @touch($config->get('concrete.cache.directory') . '/index.html', $config->get('concrete.filesystem.permissions.file'));
        }
    }
251913
protected function prepareEnvironment()
    {
        // Bind command to container
        $this->container->add('command', $this);

        // Set active connections from flag
        if ($connections = $this->command->option('on')) {
            $this->connections->setActiveConnections($connections);
        }

        // Install and load plugins if not setup already
        $vendor = $this->paths->getRocketeerPath().DS.'vendor';
        if (!$this->files->has($vendor)) {
            $this->queue->execute(Installer::class);
            $this->bootstrapper->bootstrapRocketeerDependencies();
            $this->bootstrapper->bootstrapUserCode();
        }
    }
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'] : [];
            }
        }

    }
1276524
protected function configure(): void
    {
        parent::configure();
        foreach ($this->aArguments as $aArgument) {
            $this->addArgument(
                getFromArray('name', $aArgument),
                getFromArray('mode', $aArgument, InputArgument::OPTIONAL),
                getFromArray('description', $aArgument),
                getFromArray('default', $aArgument)
            );
        }
    }
999599
protected function setUpSession () {
		if ($this->session === NULL) {
			$sessionClass = $this->application->GetSessionClass();
			$selfClass = version_compare(PHP_VERSION, '5.5', '>') ? self::class : __CLASS__;
			$this->session = $sessionClass::GetNamespace($selfClass);
			$this->session->SetExpirationSeconds($this->sessionExpirationSeconds);
		}
	}
936876
public function boot()
    {
        $env = $this->app->environment();
        $repo = $this->app->make(Repository::class);
        $cache = $this->app->make(Cache::class);
        $loaded = $cache->load($env);

        $this->app->terminating(function () use ($repo, $cache) {
            if ($repo->stale()) {
                $cache->clear();
            }
        });

        try {
            if ($loaded === false) {
                $loaded = $repo->all();
                $cache->store($env, $loaded);
            }

            $settings = array_merge($this->app->config->get('setting'), $loaded);

            $this->app->config->set('setting', $settings);
        } catch (Exception $e) {
            //
        }

        // Set the app url.
        if ($appDomain = $this->app->config->get('setting.app_domain')) {
            $this->app->config->set('app.url', $appDomain);
        }

        // Set the locale.
        if ($appLocale = $this->app->config->get('setting.app_locale')) {
            $this->app->config->set('app.locale', $appLocale);
            $this->app->translator->setLocale($appLocale);
            Date::setLocale($appLocale);
        }

        // Set the timezone.
        if ($appTimezone = $this->app->config->get('setting.app_timezone')) {
            $this->app->config->set('cachet.timezone', $appTimezone);
        }

        // Set allowed domains for CORS.
        $allowedOrigins = $this->app->config->get('cors.defaults.allowedOrigins');

        if ($allowedDomains = $this->app->config->get('setting.allowed_domains')) {
            $domains = explode(',', $allowedDomains);
            foreach ($domains as $domain) {
                $allowedOrigins[] = $domain;
            }
        } else {
            $allowedOrigins[] = $this->app->config->get('app.url');
        }

        $this->app->config->set('cors.paths.api/v1/*.allowedOrigins', $allowedOrigins);

        // Set the mail from address.
        if (!$this->app->config->get('mail.from.address')) {
            $url = parse_url($appDomain);

            if (isset($url['host'])) {
                $this->app->config->set('mail.from.address', "notify@{$url['host']}");
            }
        }

        // Set the mail from name.
        if (!$this->app->config->get('mail.from.name')) {
            $this->app->config->set(
                'mail.from.name',
                $this->app->config->get('setting.app_name', $this->app->config->get('app.name'))
            );
        }
    }