Standard Discuzx2 development process and discuzx2 Development Process
I studied the source code of discuz x2 for a month. Then I had some development experiences. Writing experiences is also a kind of review.
First, you need to understand the approximate loading process sequence of each root directory page. Here, I will not use standard files in the root directory. For example, write a new module named newModule. php.
The process is as follows:
1. newModule. php loads the core class file first./source/class/clsss_core.php is the core class file, which initializes the core object of the entire dz and uses the singleton mode. The name is $ discuz, which has several important features. First, the $ _ G parameter is referenced in the var attribute of this object, that is, $ discuz-> var = $ _ G, then, use $ this-> var in the object to operate $ _ G. Outside the object, for example, in an independent function, use $ _ G to operate the parameter; the second is that this object references all other objects, including database objects and other objects. They are all referenced to obtain the synchronous changes when they are operated in the object. (In fact, this design was originally chaotic, but it can be understood that in order to take care of the previous design, the pure OO php design is taboo and should use the registry or combination mode for better)
2. load the support file. The/source/function/function_core.php file is all core functions. What is the core function? The core functions are used when the core classes need to be instantiated.
3. the independent function required to load the module. The/source/function/function_newModule.php file is an independent function required by the module, these functions cannot be attributed to an object or class in logic or business.
4. load the class file customized by the module,/source/class/class_newModule.php file, which is used by the new module. This file can create its own extension class, especially the domain driver, or OO fans.
5. load the module's Custom Action file, which is called the action file, which is the mod in the url-based value. The purpose of this file is to provide the final entry function required by the new module.
6. After loading the above files, a large php file can be generated. All required functions are ready, and they are waiting for the submission of ajax or form or the display of template.
Note that, in fact, this is a relatively standard. Following the original dz design process, you can seamlessly sign in to dz without affecting functions because of system upgrades. It's plain. Experts have never met each other. They generally leave the dz process. However, what is destructive? It is unknown. The requirements vary from person to person.
My advice is to use OO and a few design patterns to organize code and straighten out the business, which provides better scalability and high reuse rate. Of course, you can play it if you like it. Open source. (In fact, the database can be designed. If it is me, you may not be able to design it. Do not spray it .)