Codeigniter使用什么设计模式? [英] What design pattern is Codeigniter using?

查看:275
本文介绍了Codeigniter使用什么设计模式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

相当直截了当的问题:

我知道Codeigniter是一个MVC框架 - 然而Codeigniter使用什么样的设计模式?

I know that Codeigniter is a MVC framework - however what design pattern is Codeigniter using?

从第一眼看,它似乎像Facade,但我可能是错的。

From first look it seems like Facade, but I could be wrong.

编辑:

也许我应该为不使用它的人描述Codeigniter。

在Codeigniter中,你有一个Controller和Model的概念,每个都有自己独立的文件夹。在每个文件夹中创建一个文件:
cart.php:

Perhaps I should describe Codeigniter for those who don't use it.
In Codeigniter you have a concept of a Controller and a Model, which each has their own separate folder. In each of the folders you create a file: cart.php:

<?php

class Cart {
 //...
}
?>

然后你也可以有一个模型:

Then you can also have a model:

<?php

class User {
    function login(){...}
}
?>

在课堂内,您可以使用User中的登录功能,只需使用$ this-> user-> login()

Inside of the class Cart, you can use the login function in User by simply using $this->user->login()

我发现这个很有趣,因为框架使用户对象的对象和程序员没有。

I find this interesting because the framework makes an object of the User object and the programmer does not.

推荐答案


在Codeigniter中,您有一个
控制器和模型的概念,每个都有
,文件夹。

In Codeigniter you have a concept of a Controller and a Model, which each has their own separate folder.

他们设置了他们的主要路由器类,以便搜索相应的控制器和模型文件,它甚至可以递归递归。这与任何设计模式无关,它只是一个文件夹组织。

They have setup their main router class such that it searches for corresponding controller and model files, it can even go recursive. This has nothing to do with any design pattern, it is just a folder organization.


我觉得这个有趣,因为
框架使用户
对象的对象,程序员不会。

I find this interesting because the framework makes an object of the User object and the programmer does not.

Yup,他们创造了很多东西准备制作,随时随地使用。 用户类用于控制整个用户系统。

Yup, they have created a lot of stuff ready-made and to be used any time you want. The User class is used to control whole user system.

如您所说,主要设计模式使用的是MVC,其余的东西由特定任务的不同的核心类控制。

这篇关于Codeigniter使用什么设计模式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆