問題描述
我正在尋找指導(dǎo)我了解 Controll 功能和編寫自己的控制器 + 模型的最佳實(shí)踐的教程/書籍
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
提前致謝.
推薦答案
我確信已經(jīng)發(fā)布了很多鏈接來幫助您入門,但是創(chuàng)建 MVC 的一些重要因素是:
Im sure theres plenty of links been posted to get you started but some important factors in creating an MVC is:
- 靜態(tài)注冊(cè)表類(存儲(chǔ)對(duì)象并在全局范圍內(nèi)獲取)
- 路由器(從 URI 中確定控制器/方法和參數(shù)的類)
- 基礎(chǔ)控制器(只是一個(gè)小的抽象類,然后用戶控制器可以擴(kuò)展)
- SPL 自動(dòng)加載(這將允許用戶擴(kuò)展類,例如
Model_Database
) - 結(jié)構(gòu)(根據(jù)名稱創(chuàng)建目錄,即
Library_session
會(huì)加載/library/session.class.php
) - 模型抽象(所有類型的存儲(chǔ)、數(shù)據(jù)庫、磁盤等的帳戶)
- 錯(cuò)誤跟蹤(始終確保您的日志記錄和捕獲錯(cuò)誤)
它們只是您在創(chuàng)建系統(tǒng)時(shí)應(yīng)該考慮的一些提示和想法.
They are just a few tips and ideas you should be thinking about when you create your system.
您還應(yīng)該做的是使用其他框架并構(gòu)建一些示例項(xiàng)目,了解應(yīng)該如何使用 MVC 框架,所以當(dāng)您構(gòu)建一個(gè)時(shí),您知道用戶應(yīng)該期望什么,然后真正研究框架的核心結(jié)構(gòu).
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
- 控制器(根據(jù) URI 執(zhí)行)
- 模型(從控制器訪問,應(yīng)該是數(shù)據(jù)的 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)
語言不是原始文檔中的特定語言,但在模式結(jié)構(gòu)方面被采用了幾次,下面的文件結(jié)構(gòu)示例將引導(dǎo)您了解 +L的主要用途強(qiáng)>
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
公司/項(xiàng)目使用這種方法的一個(gè)例子是:OpenCart,我強(qiáng)烈建議你看看架構(gòu)!
An example of what company / project uses this method is: OpenCart, AND I HIGHY RECOMMEND YOU LOOKING AT THE ARCHITECTURE!
這篇關(guān)于MVC - 控制器類教程的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!