Bootstrap is also called a Bootstrap program. it is a global configuration entry provided by Yaf. in Bootstrap, you can do a lot of global customization work. after a Yaf_Application is instantiated and run (Yaf_Application: run), we can choose to run Yaf_Application: bootstrap.
Bootstrap is also called a Bootstrap program. it is a global configuration entry provided by Yaf. in Bootstrap, you can do a lot of global customization work. after a Yaf_Application is instantiated and run (Yaf_Application: run), we can choose to run Yaf_Application: bootstrap.
Bootstrap () // optional call-> run ();}
When bootstrap is called, Yaf_Application searches for Bootstrap under APPLICATION_PATH by default. php, and a Bootstrap class must be defined in this file, and this class must also inherit from Yaf_Bootstrap_Abstract. (You can also modify the application in the configuration file. bootstrap to change the position of the Bootstrap class .)
After successful instantiation, all the methods defined in the Bootstrap class starting with _ init will be called in sequence, and these methods can accept a Yaf_Dispatcher instance as a parameter.
An example is provided.
GetConfig (); Yaf_Registry: set ("config", $ config);} public function _ initDefaultName (Yaf_Dispatcher $ dispatcher) {$ dispatcher-> setDefaultModule ("Index ") -> setdefacontroller controller ("Index")-> setDefaultAction ("index ");}}
The order in which methods are defined in the Bootstrap class determines the order in which they are called. for example, for the above example, _ initConfig will be called for the first time.
We can call Bootstrap to pre-process our project, such as specifying the default module and the default Controller. we will also learn how to add a route or define it in Bootstrap.