Bootstrapping refers to the process of preparing the environment before an application starts to resolve and process an incoming request. Bootstrapping is done in two places: the entry script and the application.
In the entry script, class autoloaders for different libraries are registered. This includes the Composer autoloader through its
autoload.php file and the Yii autoloader through its
Yii class file. The entry script then loads the application configuration and creates an application instance.
In the constructor of the application, the following bootstrapping work is done:
Because the bootstrapping work has to be done before handling every request, it is very important to keep this process light and optimize it as much as possible.
Try not to register too many bootstrapping components. A bootstrapping component is needed only if it wants to participate the whole life cycle of requesting handling. For example, if a module needs to register additional URL parsing rules, it should be listed in the bootstrap property so that the new URL rules can take effect before they are used to resolve requests.
Some large applications have very complex application configurations which are divided into many smaller configuration files. If this is the case, consider caching the whole configuration array and loading it directly from cache before creating the application instance in the entry script.
© 2008–2017 by Yii Software LLC
Licensed under the three clause BSD license.