Initializes the application environment.

@param string $appPath Path to the application root.

@throws BootstrapException
@throws \Exception
186344
public function initializeEnvironment($appPath)
    {
        try {
            // initialize the environment and its configurations
            $this->environment = Environment::getInstance();
            $this->environment->initializeEnvironment($appPath);
        } catch (BootstrapException $e) {
            throw $e;
        }
    }
317085
protected function bootUsingLaravel(string $path): void
    {
        $this->mergeConfigFrom("{$path}/config/form.php", 'orchestra.form');
        $this->mergeConfigFrom("{$path}/config/table.php", 'orchestra.table');

        $this->publishes([
            "{$path}/config/form.php" => \config_path('orchestra/form.php'),
            "{$path}/config/table.php" => \config_path('orchestra/table.php'),
        ]);
    }
993620
public function boot()
    {
        if ($this->app->getProps() === null) {
            return;
        }

        $routes = [];
        $pathPrefix = $this->app->getProp($this->routesPathPrefixPropName, '');
        $propRoutes = $this->app->getProp($this->routesPropName, []);

        if (!is_array($propRoutes)) {
            throw new \Exception('Routes definitions must be an array!');
        }

        foreach ($this->app->getProp($this->routesPropName, []) as $route) {
            $this->validate($route);
            $routes[] = $this->app->createRoute(
                $route['method'] ?? null,
                $pathPrefix.$route['path'],
                $route['stack']
            );
        }

        $this->app->stack($routes);
    }
1301161
public function setPaths() : ApplicationInterface
    {
        $this->container->set('app', $this);
        $paths = $this->bootstrappers->getBootstrapper()->getPaths();

        foreach ($paths->all() as $key => $path) {
            $this->container->set($key, $path);
        }

        return $this;
    }
1247932
protected function setEnvironment(Application $app)
    {
        // Define acceptable environments
        $environments = array(
            'production',
            'staging',
            'qa',
            'testing',
            'development',
            'beta',
        );

        if (! isset($_SERVER['APP_ENV'])) {
            throw new \Exception('Missing \'APP_ENV\' environment variable');
        }

        if (! in_array($_SERVER['APP_ENV'], $environments)) {
            throw new \Exception('Invalid \'APP_ENV\' environment variable: \'' + $_SERVER['APP_ENV'] +'\'');
        }

        $app['environment'] = $_SERVER['APP_ENV'];
    }
306997
public function bootstrap(Application $app)
    {
        AutoLoader::registerHandler($app->getAutoLoader());

        $app->getAutoLoader()->setCachePath(
            $app->storagePath() . DIRECTORY_SEPARATOR
            . 'cache' . DIRECTORY_SEPARATOR . "autoloader" . DIRECTORY_SEPARATOR
        );

        $app->setupAutoLoaderPaths();

//        if ($this->getStaging()->getStage()->inTesting()) {
        $app->getAutoLoader()->getClassMapLoader()->setRetry(true);
//        }
    }
1298634
protected function bootstrapContainer()
    {
        static::setInstance($this);
        
        $this->instance('app', $this);
        
        $this->bootstrapEnvironment();
        
        $this->bindPathsInContainer();
        $this->registerContainerAliases();
        $this->registerCoreServices();
        $this->registerLogBindings();
        $this->registerTheme();
    }
349733
protected function bootstrapDotenv()
    {
        if (!$this->files->has($this->paths->getDotenvPath())) {
            return;
        }

        $path = $this->files->getAdapter()->applyPathPrefix($this->paths->getBasePath());
        $dotenv = new Dotenv($path);
        $dotenv->load();
    }
463764
public static synchronized void init(String[] args, String... extraArgs) {
		AppStarter.startUp(args, extraArgs);

		status = AppStatus.INITIALIZING;

		// no implicit classpath scanning here
		boot();
	}
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());
        }
    }
985523
public function initWithFile($modelPath, $policyPath)
    {
        $adapter = new FileAdapter($policyPath);
        $this->initWithAdapter($modelPath, $adapter);
    }
1125151
private function loadApplicationConfig()
    {
        // load the config
        try{
            $this->applicationConfig = $this->config()->yaml($this->applicationAbsolutePath . 'App/Config/App.yaml');
        }catch (\Exception $e){
            throw new BootstrapException('Unable to read app config file: '.$this->applicationAbsolutePath . 'App/Config/App.yaml');
        }

    }
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();
        }
    }
502655
public function boot(Application $app)
    {
        $app['twigwrapper'] = new TwigWrapper($app[$this->twigIdentifier], $this->postProcessors);
    }
648757
private function init(string $path)
    {
        $this->_path = $path;

        if (!file_exists($this->_path)) {
            throw new FileNotExistsException('file ' . $this->_path . ' not exists');
        }

        $type = FileTool::type($this->_path);
        if ('file' !== $type) {
            throw new NotFileException('type of ' . $this->_path . ' is ' . $type . ' (not file)');
        }
    }
389929
protected function bootstrapContainer()
    {
        static::setInstance($this);

        $this->instance('app', $this);
        $this->instance(self::class, $this);

        $this->instance('path', $this->path());
        $this->instance('path.base', $this->basePath());
        $this->instance('path.config', $this->basePath('resources/config'));
        $this->instance('path.database', $this->databasePath());
        $this->instance('path.storage', $this->storagePath());
        $this->instance('path.resources', $this->resourcePath());
        $this->instance('path.bootstrap', $this->bootstrapPath());

        $this->instance('env', $this->environment());

        $this->registerContainerAliases();
    }
1178479
public function bootstrap(Application $app)
	{
		Facade::clearResolvedInstances();

		Facade::setFacadeApplication($app);

		AliasLoader::getInstance($app['config']['app.aliases'])->register();
	}