Table of Contents
Discuzx2开发标准流程,discuzx2开发流程
Home php教程 php手册 Discuzx2开发标准流程,discuzx2开发流程

Discuzx2开发标准流程,discuzx2开发流程

Jun 13, 2016 am 08:43 AM
virtual host

Discuzx2开发标准流程,discuzx2开发流程

研究了有一个月的discuz x2的源代码。然后有了一些开发的心得。写心得也算是一种回顾,温故而知新嘛。

 

首先,要理解每一个根目录页面的大概的加载流程顺序。这里,我就不用根目录的标准文件了。直接举例,写一个新的模块,它的名字叫做newModule.php。

 

流程是这样的:

1. newModule.php首先加载核心的类文件,/source/class/clsss_core.php这个是核心的类文件,这个文件是初始化了整个dz的核心对象,用了单例模式。名字叫做$discuz,这个对象里面有几个比较重要的特点。首先,是$_G的参数,被引用到了这个对象的var属性中,也就是$discuz->var = $_G,然后在对象内用$this->var来操作$_G,在对象外面,比如独立函数中,使用$_G来操作参数;其次是这个对象里面引用了所有的其他对象,包括数据库对象和其他对象,都是用引用来获得在对象内操作的它们时的同步改变。(其实这个设计原本就比较混乱,不过可以理解,为了照顾以前的设计,纯OO的php设计是忌讳这样的,应该使用注册表或者组合模式来得更好)

2. 加载支持文件,/source/function/function_core.php文件是所有核心函数,何谓核心函数,核心函数的意思就是在核心类需要实例化的时候,它们就会被使用到。

3. 加载模块所需要的独立函数, /source/function/function_newModule.php文件,是该模块自己所需要的独立的函数,这些函数应该是从逻辑或者是业务上来说是不能被归结到某个对象或者类里面。

4. 加载模块自定义的类文件,/source/class/class_newModule.php文件,这个文件是新模块所需要用到类,这个文件可以创建自己的扩展类,特别是领域驱动,或者OO爱好者。

5. 加载模块自定义的动作文件,什么叫动作文件,就是url传值中的mod,这文件的作用是,如果提供最后这个新模块所需要的最终入口函数。

6. 加载完以上文件,那么,就可以产生了一个可以供用来使用的大块php的。所有的必须要的函数都已经准备,就等着ajax或者form的提交或者template的显示。

 

需要注意一点是:其实这里是一个比较标准的,遵从dz原本设计的流程,可以无缝的内签到dz中,而不会因为系统升级从来影响功能。淡然了。高手们从来都不满足的,他们一般都会脱离dz的流程。不过,破坏性怎么样?就不得而知了。需要因人而异。

 

我的建议是使用OO和少许的设计模式,来组织代码,理顺业务,这样扩展性较好,复用率高。当然,喜欢怎么玩,就怎么玩。开源的嘛。(其实数据库感觉设计的可以,如果是我,想必设计不出来,高手勿喷。)

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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

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

Hot Article

Roblox: Bubble Gum Simulator Infinity - How To Get And Use Royal Keys
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Nordhold: Fusion System, Explained
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Mandragora: Whispers Of The Witch Tree - How To Unlock The Grappling Hook
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

Java Tutorial
1670
14
PHP Tutorial
1274
29
C# Tutorial
1256
24
How to set the speed limit of the virtual host through the Pagoda panel How to set the speed limit of the virtual host through the Pagoda panel Jun 21, 2023 am 11:17 AM

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

Detailed explanation of the virtual host and domain name binding functions of the Gin framework Detailed explanation of the virtual host and domain name binding functions of the Gin framework Jun 22, 2023 am 09:10 AM

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

What are the free php virtual hosts abroad? What are the free php virtual hosts abroad? Oct 16, 2023 am 09:57 AM

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

How PHP connects to Tencent Cloud Server ECS to implement cloud virtual host deployment How PHP connects to Tencent Cloud Server ECS to implement cloud virtual host deployment Jul 07, 2023 am 10:07 AM

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

How Nginx implements domain name-based virtual host configuration How Nginx implements domain name-based virtual host configuration Nov 08, 2023 pm 08:05 PM

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

How to use Pagoda Panel for virtual host security protection How to use Pagoda Panel for virtual host security protection Jun 21, 2023 pm 05:37 PM

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

Nginx virtual host optimization configuration to improve website performance and user experience Nginx virtual host optimization configuration to improve website performance and user experience Jul 04, 2023 pm 05:55 PM

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

Apache Virtual Hosting: Hosting Multiple Websites on a Single Server Apache Virtual Hosting: Hosting Multiple Websites on a Single Server Mar 31, 2025 pm 04:05 PM

ApacheVirtualHosting allows hosting multiple websites on one server. 1) When configuring a virtual host, you need to add blocks in the configuration file and specify ServerName and DocumentRoot. 2) Advanced configuration can include setting up SSL certificates for different websites. 3) Performance optimization suggestions include using name-based virtual hosts, enabling KeepAlive, and caching.

See all articles