Framework running process Such a get request http ://Hostname/Index. php? Route = common/home what happened? 1. start to execute the entry file index. php. 2. require_once (DIR_SYSTEM. 'Startup. php '); Make some php configuration and load some class declarations, including the system Main framework File (file under system/engine), some necessary helper and library. The system's main framework files include: Registry: Stores global variables. the registrant mode, controller base class, model base class, and loader are used to store references to this object. I did not write the Singleton mode. I may want to make this class more generic. I can add a new registry instance for sharing among several objects; Loader: it is used to dynamically load other files and provides the ability to load model, library, helper, database, config, and language, when model and database are loaded, an instance is created and saved to the registry object. for data classes, only one instance is required; Controller, model: the base class of the controller and the base class of the data model class, the function is very simple; Action: a user's request, corresponding to an action, uses the query parameter route of the request to initialize the action; Front: request distributor, dispatch action; The following Framework process describes what these classes have done. 3. initialize registry, loader, db, error handling functions, and libraries used in the future, and save the reference of these library instances to the registry object, which is then directly used by the controller and model objects. 4. initialize the front and action objects. at this time, the action is constructed by the query parameter route value "common/home" in the url. The action resolves the corresponding controller file name, class name, and method and parameter to be executed. 5. the front sends an action. based on the class name attribute of the action, the controller object ControllerCommonHome (catalog/controller/common/home. php), initialize it with registry, and then execute ControllerCommonHome-> index () according to the action method index (if no method is passed, the default value is index) and parameter attribute (none (), in the index method, the service logic is processed, the template is loaded, and the content to be output to the browser is saved to the response. Note that the magic methods _ get and _ set of the controller take values and assign values from the registry object. Therefore, you can use the objects stored in the registry just like using your own attributes. For example, $ this-> load-> model ('catalog/category ') calls the model method of the loader object. 6. the last $ response-> output () line in index. php returns the content to the user. So far, the framework has processed the user's request. See also an opencart plug-in I wrote opencart Baidu login and Baidu Wallet payment plug-in responsive adaptation to pc/mobile |