Bootstrap method to be called during application bootstrap stage.

@param Application $app the application currently running
163587
public function bootstrap($app)
    {
        if ($app instanceof yii\web\Application) {
            Yii::$container->set('yii\widgets\ActiveForm', function ($di, $params, $config) {
                if (!isset($config['id'])) {
                    $config['id'] = str_replace('.', '_', uniqid('ActiveForm_', true));
                }

                return new yii\widgets\ActiveForm($config);
            });
        }
    }
633287
public function boot(Application $app)
    {
        $paths = $app['lazy.thumbnail.mount_paths'];
        foreach ($paths as $route => $data) {
            $realRoute = isset($data['route']) ? $data['route'] : $route;
            $app->mount($realRoute, $this->connect($app, $realRoute, $data));
        }
    }
712603
public function run(Application $app)
    {
        $this->trigger(self::EVENT_BEFORE_RUN);
        if (count($this->_afterCallbacks) > 0) {
            $this->runCommandInForeground($app);
        } else {
            $this->runCommandInBackground($app);
        }
        $this->trigger(self::EVENT_AFTER_RUN);
    }
1146027
public function register(Application $app)
    {
        $this->loadProviders();

        foreach ($this->controllerProviders as $class => $values) {
            $app->register(new $class, $values);
        }
    }
526735
public function bootstrap($app)
    {
        if ($app instanceof \yii\console\Application) {

            // add deferred module
            $app->setModule('deferred', new DeferredTasksModule('deferred', $app));

            // this will automatically add deferred controller to console app
            $app->controllerMap['deferred'] = [
                'class' => DeferredController::className(),
            ];

        }
        $app->i18n->translations['deferred-tasks'] = [
            'class' => 'yii\i18n\PhpMessageSource',
            'basePath' => __DIR__ . DIRECTORY_SEPARATOR . 'messages',
        ];

        DeferredQueueEvent::on(
            DeferredController::className(),
            DeferredController::EVENT_DEFERRED_QUEUE_COMPLETE,
            [QueueCompleteEventHandler::className(), 'handleEvent']
        );
    }
1143464
protected function bootstrapExtensions($app)
    {
        $rhoone = Yii::$app->rhoone;
        /* @var $rhoone \rhoone\base\Rhoone */
        $extensions = $rhoone->extensions;
        if (empty($extensions)) {
            return 0;
        }
        foreach ($extensions as $id => $extension) {
            if ($extension instanceof BootstrapInterface) {
                try {
                    $extension->bootstrap($app);
                } catch (\Exception $ex) {
                    Yii::error($ex->getMessage(), __METHOD__);
                    continue;
                }
            }
        }

        $count = 0;
        foreach ($extensions as $ext) {
            $moduleConfig = [];
            try {
                $moduleConfig = $ext->getModule();
            } catch (\Exception $ex) {
                continue;
            }
            if (empty($moduleConfig)) {
                continue;
            }
            Yii::info("`" . $moduleConfig['id'] . '` enabled.', __METHOD__);
            $app->setModule($moduleConfig['id'], $moduleConfig);
            $module = $app->getModule($moduleConfig['id']);
            if ($module instanceof BootstrapInterface) {
                $app->bootstrap[] = $module->id;
                Yii::trace('Bootstrap with ' . $module->className() . '::' . 'bootstrap()', __METHOD__);
                $module->bootstrap($app);
                $count++;
            }
        }
        return $count;
    }
990443
protected function callAfterCallbacks(Application $app)
    {
        foreach ($this->_afterCallbacks as $callback) {
            call_user_func($callback, $app);
        }
    }
462052
public function bootstrap(Application $app)
    {
        $this->app = $app;
        define('DEBUG', (ENVIRON == 'local' || ENVIRON == 'test'));
        if (DEBUG) {
            error_reporting(E_ALL ^ E_NOTICE);
            ini_set('display_errors', 'On');
        } else {
            error_reporting(0);
            ini_set('display_errors', 'Off');
        }
        set_error_handler([$this, 'handleError']);
        set_exception_handler([$this, 'handleException']);
        register_shutdown_function([$this, 'handleShutdown']);
    }
426515
public function bootstrap($app)
    {

        if ($app instanceof \yii\web\Application) {
            $started = false;
            $search = null;
            if (false === empty($this->searchClass)) {
                if (true === class_exists($this->searchClass)) {
                    $config = array_merge(['class' => $this->searchClass], $this->searchConfig);
                    $search = Yii::createObject($config);
                    $started = $search->getStarted();
                }
                if (false === $started) {
                    $search = new Search;
                }
                $this->search = $search;
            }
            $this->controllerMap['sort'] = [
                'class' => SortController::className(),
            ];
        }
        if ($app instanceof \yii\console\Application) {
            if ($this->searchClass === Elastic::class) {
                $this->controllerMap['elastic'] = [
                    'class' => ElasticIndexController::class,
                ];
            }
            $this->controllerMap['translate-eav'] = [
                'class' => TranslateEavController::class,
            ];
        }

        $this->registerTranslations();
    }
1092880
public function boot(Application $app)
    {
        if (!$this->registered) {
            throw new \RuntimeException('Can not boot extensions prior to completion of registration.');
        }
        if ($this->booted) {
            throw new \RuntimeException('Can not re-boot extensions.');
        }

        // Boot all extension loaders that are also service providers
        foreach ($this->extensions as $extension) {
            if ($extension->isEnabled() !== true) {
                continue;
            }
            foreach ($extension->getInnerExtension()->getServiceProviders() as $provider) {
                $provider->boot($app);
            }
        }
        $this->loaded = true;
        $this->booted = true;
    }
466338
public function bootstrap($app)
    {
        if ($app instanceof WebApplication) {
            $this->addUrlManagerRules($app);
            $this->setPodiumLogTarget($app);
        } elseif ($app instanceof ConsoleApplication) {
            $this->controllerNamespace = 'bizley\podium\console';
        }
    }
1073229
public function bootstrap($app)
    {
        if ($app->hasModule('user') && ($module = $app->getModule('user')) instanceof Module) {
            //监听用户活动时间
            /** @var \yii\web\UserEvent $event */
            $app->on(Application::EVENT_AFTER_REQUEST, function ($event) use ($app) {
                if (!$app->user->isGuest && Yii::$app->has('queue')) {
                    $user = UserExtra::findOne(['user_id' => $app->user->id]);
                    $user->updateAttributesAsync(['last_visit' => time()]);
                }
            });

            //监听用户登录事件
            /** @var \yii\web\UserEvent $event */
            $app->user->on(User::EVENT_AFTER_LOGIN, function ($event) use ($app) {
                //记录最后登录时间记录最后登录IP记录登录次数
                $user = UserExtra::findOne(['user_id' => $app->user->id]);
                $user->updateAttributesAsync(['login_at' => time(), 'login_ip' => Yii::$app->request->userIP]);
                $user->updateCountersAsync(['login_num' => 1]);
            });
        }
    }
1275876
public function boot(Application $app)
	{
		$assets = $this;
		$app->before(function(Request $request) use($app, $assets){
			$baseUrl = rtrim($request->getScheme().'://'.$request->getHttpHost().$request->getBasePath()).'/';
			$assets->setCoreUrl($baseUrl);
			$assets->setOption('baseUrl', $baseUrl);
			$assets->setOption('jsPosition',$assets::ON_BODY);
			return $assets;
		});

		// Registering preloaded options
		$options = isset($app['assets.options'])?$app['assets.options']:array();
		if(!empty($options))
			array_walk($options, function($optionValue, $optionName) use($assets){
				$assets->setOption($optionName, $optionValue);
			});	

		// Registering preloaded javascript files
		$js = isset($app['assets.js'])?$app['assets.js']:array();
		if(!empty($js))
			array_walk($js, function($value) use($assets){
				$assets->registerJs($value);
			});

		// Registering preloaded css files
		$css = isset($app['assets.css'])?$app['assets.css']:array();
		if(!empty($css))
			array_walk($css, function($value) use($assets){
				$assets->registerCss($value);
			});

		$app->after(function(Request $request, Response $response) use($app, $assets){
			// print_r($response->headers->get('content_type'));
			if($response->headers->get('content_type')!='application/json')
			{
				$content = $response->getContent();
				$assets->renderAssets($content);
				$response->setContent($content);
			}
			return $response;
		});
	}
1147240
public function bootstrap(Application $app)
    {
        try
        {
            Dotenv::makeMutable();
            Dotenv::load($app->environmentPath(), $app->environmentFile());
            Dotenv::makeImmutable();
        } catch (InvalidArgumentException $e)
        {
            //
        }

        $app->detectEnvironment(
            function ()
            {
                return env('APP_ENV', 'production');
            }
        );
    }
342547
public function bootstrap(Container $app)
    {
        foreach ($app->make('config')->get('app.providers') as $provider) {
            $app->register(new $provider($app));
        }
        
        foreach ($app->make('config')->get('app.theme.providers', []) as $provider) {
            $app->register(new $provider($app));
        }
    }
940681
public function bootstrap(Container $app)
    {
        Facade::clearResolvedInstances();
        
        Facade::setFacadeApplication($app);
        
        AliasLoader::getInstance($app->make('config')->get('app.aliases'))->register();
        AliasLoader::getInstance($app->make('config')->get('app.theme.aliases', []))->register();
    }
566560
public function bootstrap($app)
    {
//        \Yii::setAlias('@mtengii','@vendor/mootensai/yii2-enhanced-gii');
        if ($app->hasModule('gii')) {
            if (!isset($app->getModule('gii')->generators['enhanced-gii'])) {
                $app->getModule('gii')->generators['enhanced-gii-model'] = 'mootensai\enhancedgii\model\Generator';
                $app->getModule('gii')->generators['enhanced-gii-crud']['class'] = 'mootensai\enhancedgii\crud\Generator';
//                $app->getModule('gii')->generators['enhanced-gii-crud']['templates'] = [
//                    'default' => '@mtengii/crud/default',
//                    'nested' => '@mtengii/crud/nested'
//                ];
                $app->getModule('gii')->generators['enhanced-gii-migration'] = 'mootensai\enhancedgii\migration\Generator';
            }
        }
    }