Home > Backend Development > PHP Tutorial > Discuzx2 development standard process, discuzx2 development process_PHP tutorial

Discuzx2 development standard process, discuzx2 development process_PHP tutorial

WBOY
Release: 2016-07-12 08:55:29
Original
847 people have browsed it

Discuzx2 development standard process, discuzx2 development process

I have studied the source code of discuz x2 for a month. Then I got some development experience. Writing experiences can be considered a kind of review, reviewing the past and learning the new.

First of all, you need to understand the approximate loading process sequence of each root directory page. Here, I won't use the standard files in the root directory. To take a direct example, write a new module and its name is newModule.php.

The process is as follows:

1. newModule.php first loads the core class file, /source/class/clsss_core.php is the core class file. This file initializes the core object of the entire dz, using the singleton mode. The name is $discuz, and this object has several important features. First, the parameters of $_G are referenced to the var attribute of this object, that is, $discuz->var = $_G, and then use $this->var to operate $_G inside the object, and outside the object, For example, in an independent function, $_G is used to operate parameters; secondly, this object references all other objects, including database objects and other objects, and uses references to obtain synchronized changes when operating them within the object. (In fact, this design was originally quite confusing, but it is understandable. In order to take care of the previous design, pure OO PHP design is taboo like this. It is better to use the registry or combination mode)

2. Load the support files. The /source/function/function_core.php file contains all core functions. What are core functions? Core functions mean that they will be used when core classes need to be instantiated.

3. The independent functions needed to load the module, the /source/function/function_newModule.php file, are independent functions needed by the module itself. These functions should not be attributed to logic or business. inside an object or class.

4. Load the module’s customized class file, /source/class/class_newModule.php file. This file is the class needed by the new module. This file can create your own extension class, especially domain driver, or OO Enthusiast.

5. Load the module's customized action file. What is an action file? It is the mod in the URL value. The function of this file is to provide the final entry function required by the new module.

6. After loading the above files, a large piece of php that can be used will be generated. All necessary functions have been prepared, just waiting for ajax or form submission or template display.

One thing to note is: in fact, this is a relatively standard one. It follows the process originally designed by dz and can be seamlessly signed into dz without affecting the functions due to system upgrades. Calm down. Experts are never satisfied, and they usually break away from the dz process. But what about destructiveness? It’s unknown. Needs vary from person to person.

My suggestion is to use OO and a few design patterns to organize the code and streamline the business, so that the scalability is better and the reuse rate is high. Of course, you can play however you like. It's open source. (Actually, the database seems to be well designed. If it were me, I probably wouldn’t be able to design it. Experts, please don’t criticize me.)

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1116660.htmlTechArticleDiscuzx2 development standard process, discuzx2 development process has studied the source code of discuzx2 for a month. Then I got some development experience. Writing experiences is also a kind of review, reviewing the past and learning the new...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template