


Discuzx2 development standard process, discuzx2 development process_PHP tutorial
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.)

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



Pagoda Panel is a very excellent server management panel under Linux system. It has powerful functions and friendly interface, which can help users manage servers easily. In the process of using the Pagoda Panel, it is sometimes necessary to limit the speed of the virtual host to ensure the stability and fluency of the server. This article will introduce how to set the speed limit of the virtual host through the Pagoda panel to achieve a good user experience. 1. Overview of Speed Limit Speed limit refers to limiting the host bandwidth and ensuring the normal operation of the server by controlling the host traffic. exist

The Gin framework is a lightweight web framework that provides the basic functionality needed to quickly build web applications. The Gin framework is flexible, efficient, and scalable, so it is widely used in the Internet field. Among them, the virtual host and domain name binding functions of the Gin framework are important features that other web frameworks do not have. This article will introduce this function in detail. 1. What is a virtual host? A virtual host creates multiple independent and mutually isolated virtual hosts on a physical host. Each virtual host has its own unique

How PHP connects to Tencent Cloud Server ECS to implement cloud virtual host deployment Introduction: With the rapid development of cloud computing, more and more enterprises and developers choose to deploy applications to cloud servers to obtain better elasticity and security. and scalability. This article will introduce how to use PHP to connect with Tencent Cloud Server ECS (Elastic Compute Service) to implement cloud virtual host deployment. Step 1: Create a Tencent Cloud Server ECS instance. First, we need to

Foreign free php virtual hosts include DreamHost, Bluehost, Hostinger, 000Webhost, FreeHostia, Zymic, ByetHost and SiteGround.

In the Internet age, web hosting is a very popular service that allows users to own their own website and manage it easily. However, when using virtual hosts, security issues must also attract our attention. In response to this situation, Pagoda Panel provides a good solution that can help us better protect the security of the virtual host. This article will introduce how to use the Pagoda panel to protect the security of virtual hosts. 1. Set the login password and port. Before using the Pagoda panel, the first step is to set a secure login password. default

How Nginx implements domain name-based virtual host configuration requires specific code examples. Nginx is a high-performance HTTP and reverse proxy server that provides flexible configuration options to implement domain name-based virtual host configuration. In this article, we will introduce in detail how to configure Nginx to implement domain name-based virtual hosting and provide specific code examples. First, we need to add the virtual host configuration block to the Nginx configuration file. On Ubuntu systems, the default configuration file path is /et

Nginx virtual host optimization configuration to improve website performance and user experience Introduction: Nowadays, with the continuous development of the Internet, the number of visits to the website is also increasing. As the entrance to the website, the optimized configuration of Nginx plays a crucial role in improving website performance and user experience. This article will introduce some methods for optimizing the configuration of Nginx virtual hosts, along with code examples so that you can better understand and apply them. 1. Configuration of virtual host Virtual host is an important concept in Nginx. Through the configuration of virtual host, we can

How to use Nginx to implement virtual host configuration based on domain name and path Introduction: In network application development, it is often necessary to configure multiple virtual hosts to provide different services. Nginx is a high-performance HTTP and reverse proxy server. By using Nginx, we can easily implement virtual host configuration based on domain name and path. This article will introduce how to use Nginx to implement such a configuration and give corresponding code examples. 1. The virtual host based on the domain name is configured in the Nginx configuration file, using
