- 1 Introduction
- 1.1 About zentaoPHP
- 1.2 Features
- 1.3 License
- 2 Installation
- 2.1 System Requirement
- 2.2 Install zentaoPHP
- 3 Quick Start
- 3.1 Echo Hello World!
- 3.2 Use MVC to echo Hello World!
- 3.3 Example: Deploy the blog built in zentaoPHP
- 4 Basics
- 4.1 Basic Concepts
- 4.2 Request Types
- 4.3 Create Links
- 4.4 Class: HTML, JS, and CSS
- 5 Advanced
- 5.1 Directory Structure
- 5.2 DAO
- 5.3 Pager Solutions
- 5.4 Data Validation
Basic Concepts
- 2018-07-12 10:38:35
- tengfei
- 7469
- 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.