Home Backend Development PHP Tutorial 松耦合的模块化开发有关问题

松耦合的模块化开发有关问题

Jun 13, 2016 am 11:59 AM
cms mvc nbsp php web

松耦合的模块化开发问题
现在的web项目越来越复杂,越来越注重项目代码的复用与伸展自如。
比如,一个企业的cms项目,有“文本”模块、“图片”模块、“视频”模块、“身份验证”模块等等,而这些模块之间是相互穿插的,“文本”模块可以有“图片模块”,“视频”模块中需要“身份验证”等等,当这些模块组成一个cms时,依客户要求不同,是分“精简”版、“标准”版、“加强”版等版本的,越复杂的版本,加载的模块越多,但怎样才能保持当模块移除时保证核心库与其它模块正常工作呢?!或者说可以依需求动态加载其它模块?!或者说实现PHP的敏捷开发?!
------解决方案--------------------
这个,只能是考虑的多点。
也就是说,想到全面一些。

也没什么好的办法。

我们每天都在开发,如果能真的综合一下的。是可以的。
------解决方案--------------------
我一般是这么解决的,自定义模型和封装类
如果你懂MVC,那么你看下面的话应该很容易明白,如果不懂,先了解下MVC和类吧

M就是模型,自定义模型其实很简单,在开发中其实大部分的东西都可以抽象为模型,每个模型可以有很多属性(字段),那么只要在模型中,可以动态的处理字段就好(比如:文本字段,选择字段,图片字段,编辑器字段),只要创建好模型后,集成公用的基础类和基础方法,大部分的内容都可以解决了
C:就是控制器,在继承了公用控制器后(方法随你,比如模板解析之类的方法),如果在业务上还有其他需求,那么就在当前类控制器中增加相应的方法
V:就是视图了,视图其实就是前台显示,也可以理解为模板。
只要有一个基础类,剩下的继承上一层,这样可以做到耦合降低。
比如:核心类 —— 前台类, 后台类 —— 前台自定义模型产生的类,后台自定义模型产生的类。
下级的,下级只依赖上级,上级与下级无耦合,同级之间无耦合。

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

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
4 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)

CakePHP Project Configuration CakePHP Project Configuration Sep 10, 2024 pm 05:25 PM

In this chapter, we will understand the Environment Variables, General Configuration, Database Configuration and Email Configuration in CakePHP.

PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian Dec 24, 2024 pm 04:42 PM

PHP 8.4 brings several new features, security improvements, and performance improvements with healthy amounts of feature deprecations and removals. This guide explains how to install PHP 8.4 or upgrade to PHP 8.4 on Ubuntu, Debian, or their derivati

CakePHP Date and Time CakePHP Date and Time Sep 10, 2024 pm 05:27 PM

To work with date and time in cakephp4, we are going to make use of the available FrozenTime class.

CakePHP File upload CakePHP File upload Sep 10, 2024 pm 05:27 PM

To work on file upload we are going to use the form helper. Here, is an example for file upload.

CakePHP Routing CakePHP Routing Sep 10, 2024 pm 05:25 PM

In this chapter, we are going to learn the following topics related to routing ?

Discuss CakePHP Discuss CakePHP Sep 10, 2024 pm 05:28 PM

CakePHP is an open-source framework for PHP. It is intended to make developing, deploying and maintaining applications much easier. CakePHP is based on a MVC-like architecture that is both powerful and easy to grasp. Models, Views, and Controllers gu

How To Set Up Visual Studio Code (VS Code) for PHP Development How To Set Up Visual Studio Code (VS Code) for PHP Development Dec 20, 2024 am 11:31 AM

Visual Studio Code, also known as VS Code, is a free source code editor — or integrated development environment (IDE) — available for all major operating systems. With a large collection of extensions for many programming languages, VS Code can be c

CakePHP Creating Validators CakePHP Creating Validators Sep 10, 2024 pm 05:26 PM

Validator can be created by adding the following two lines in the controller.

See all articles