MVC - 控制器类教程 [英] MVC - Controller class tutorial

查看:28
本文介绍了MVC - 控制器类教程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找指导我了解 Controll 功能和编写自己的控制器 + 模型的最佳实践的教程/书籍

I am looking for a tutorial / book that guides me to understand the Controll functions and the best practices to write my own controller + Model

提前致谢.

推荐答案

我确信已经发布了很多链接来帮助您入门,但是创建 MVC 的一些重要因素是:

Im sure theres plenty of links been posted to get you started but some important factors in creating an MVC is:

  • 静态注册表类(存储对象并在全局范围内获取)
  • 路由器(从 URI 中确定控制器/方法和参数的类)
  • 基础控制器(只是一个小的抽象类,然后用户控制器可以扩展)
  • SPL 自动加载(这将允许用户扩展类,例如 Model_Database)
  • 结构(根据名称创建目录,即Library_session会加载/library/session.class.php)
  • 模型抽象(所有类型的存储、数据库、磁盘等的帐户)
  • 错误跟踪(始终确保您的日志记录和捕获错误)

它们只是您在创建系统时应该考虑的一些提示和想法.

They are just a few tips and ideas you should be thinking about when you create your system.

您还应该做的是使用其他框架并构建一些示例项目,了解应该如何使用 MVC 框架,所以当您构建一个时,您知道用户应该期望什么,然后真正研究框架的核心结构.

What you should also do is user other frameworks and build some sample projects, learn how an MVC Framework should be sued, so when your building one you know what the user should expect, then just really study the core structure of the framework.

在 PHP 中考虑以下通常是 MVC 的工作方式

Take into consideration in PHP the following are usually how MVC Works

  • 控制器(根据 URI 执行)
  • 模型(从控制器访问,应该是数据的 I/O)
  • 查看(基本上是模板)

但您可以使用 MVCL,即 (M odel/V iew/C ontroller/L 语言)

but you can work with a MVCL which is (M odel/V iew/C ontroller/L language)

语言不是原始文档中的特定语言,但在模式结构方面被采用了几次,下面的文件结构示例将引导您了解 +L

Language is not a specific in the original documentation but its been adopted a few times in regards to the pattern structure, An example of the file structure below will guide you into whats the main purpose of the +L

M: catalogmodelcatalogproduct.php
V: catalogview	emplateproductproduct.tpl
C: catalogcontrollerproductproduct.php
L: cataloglanguageenglishproductproduct.php

公司/项目使用这种方法的一个例子是:OpenCart,我强烈建议你看看架构!

An example of what company / project uses this method is: OpenCart, AND I HIGHY RECOMMEND YOU LOOKING AT THE ARCHITECTURE!

这篇关于MVC - 控制器类教程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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