Basic Concepts

2018-07-12 10:38:35
tengfei
5811
Last edited by tengfei on 2019-09-16 14:11:01

All requests in zentaoPHP are carried out through index.php. Its basic principle is to pass all requests to index.php by setting up Apache or other webservers.


Index.php loads the files, initializes the application, analyze the requests, and get the request to the correspondent module name, method and parameter. Then it loads the corresponding module and control methods, then render the template,  and display to the user. The basic model is as follows:

1. routerRouter

Router is index.php in zentaoPHP. Through the configuration file of Apache, all requests from one domain name can be resolved to this index.php file. Then the index.php is responsible for scheduling.


2. app

Router will instantiate a specific application according to the current request. For example, the index.php code for demo applications is as follows:


include './framework/router.class.php';
include './framework/control.class.php';
include './framework/model.class.php';
include './framework/helper.class.php';
$app = router::createApp('demo');



3.  config, lang, dbh

When an app is instantiated, it loads the configuration file of the app to generate $config objects.

Then it is connected to the database to generate the $dbh object.

Then the language files of the common module will be loaded to generate $lang objects.


4. URI,module,control, model and view

When the application loads the configuration file and the language file, it will parse the current requests, that is, URI, and get the module and its method and parameter to be invoked.

Module is one of the modules of the application. The module is composed of control, model, view and lang files.

Control is the control file of module, which is responsible for organizing various service logic (model), and then displaying corresponding view files.

For example, the control class of the blog in demo application defines index, view, del, edit, add and so on.

The corresponding model class defines getList, getInfo, delArticle, add and so on.


Write a Comment
Comment will be posted after it is reviewed.