我正在尝试使用Front Controller Design深入研究MVC.
我想通过使用一行来调用我的整个应用程序,例如在index.php中:
require_once(myclass.php);
$output = new myClass();
Run Code Online (Sandbox Code Playgroud)
我很想摆脱require_once线,但我不知道如何加载我的课程而不包括它?
无论如何,我的主要问题是如何使用一个前端类加载我的各种控制器和模型和视图等.到目前为止,我想出了:
class myClass
{
private $name;
public $root = $_SERVER['DOCUMENT_ROOT'];
private $route = array("Controller" => "", "Model" => "", "View" => "", "Paremeters" => "");
function __construct()
{ $uri = explode("/",$_SERVER['REQUEST_URI']);
if(isset($uri[2])) {$this->route['Controller'] = $uri[2];}
if(isset($uri[3])) {$this->route['Model'] = $uri[3];}
if(isset($uri[4])) {$this->route['View'] = $uri[4];}
if(isset($this->route['Controller']))
{
include($this->root."/".$this->route['Controller'].".php");
}
}
}
Run Code Online (Sandbox Code Playgroud)
但它看起来有点令人费解并超过顶部.此外,一旦我在__construct中包含了新类,我该如何加载它?
我很抱歉缺乏知识,我已经多次用Google搜索,我不断提出相同的页面似乎并没有扩展我对这个问题的了解.
我使用查询字符串做了前端控制器.
例如:
但是我需要在不使用查询字符串的情况下完成它.
上下文:我打算使用mod_rewrite(首页加载子页面)构建应用程序,但是却停留在从前端控制器页面加载session_enabled页面.
问题:问题是我使用session_start()调用twise,PHP页面停止响应.奇怪的是,session_start函数是无害的,它们在不同的页面上调用.
我已经将问题缩小到这个样本:
child.php文件:
parent.php文件:
调用parent.php将使浏览器无限加载.只要您对session_start()调用之一进行评论,它就会立即加载.
这个问题的根源是什么?我非常需要启用会话的页面.
PS我可以通过包含页面来解决它,但它们依赖于URL参数,我想避免为了某种参数代理而修复它们.
我目前正在设置我的网站,主要是用PHP.虽然这是我第一次使用它,所以我遇到了一些问题.
我已经了解了该网站的基础知识.注册,登录,个人资料页等等.但是,我似乎必须对网站布局做出决定.
例如.目前,用户的个人资料页面的URL为
mysite.com/profile.php
理想情况下,我想要的是它的某些东西
mysite.com/user/ChrisSalij
从阅读这些内容我认为我需要一个Front Controller风格的网站,虽然我不确定这一点,也不知道从哪里开始实现一个.
请记住,我是一个非常新的PHP等,我会感谢任何有用的评论,链接和建设性的批评.
我非常愿意学习,所以链接到文章和解释会非常好.我经常对这样的事情进行大量的研究.但我是新手,我不知道从哪里开始.
编辑:我还应该补充一点,我计划将这个网站扩展到大规模.它很小,但如果我的目标成功,应该会有很多页面.因此,我愿意现在付出努力,使其长期正确.谢谢
(ACF9)
除非有一个我缺少的选项,"记录慢于[n]秒的慢速页面"设置对于基于前端控制器的站点没有用(例如,Model-Glue,FW/1,Fusebox,Mach-II,等等.).
例如,在Mura/Framework-One网站中,我最终得到:
"Warning","jrpp-186","04/25/13","15:26:36",,"Thread: jrpp-186, processing template: /home/mysite/public_html_cms/wwwroot/index.cfm, completed in 11 seconds, exceeding the 10 second warning limit"
"Warning","jrpp-196","04/25/13","15:27:11",,"Thread: jrpp-196, processing template: /home/mysite/public_html_cms/wwwroot/index.cfm, completed in 59 seconds, exceeding the 10 second warning limit"
"Warning","jrpp-214","04/25/13","15:28:56",,"Thread: jrpp-214, processing template: /home/mysite/public_html_cms/wwwroot/index.cfm, completed in 32 seconds, exceeding the 10 second warning limit"
"Warning","jrpp-134","04/25/13","15:31:53",,"Thread: jrpp-134, processing template: /home/mysite/public_html_cms/wwwroot/index.cfm, completed in 11 seconds, exceeding the 10 second warning limit"
Run Code Online (Sandbox Code Playgroud)
有没有办法在那里获取查询字符串或发布详细信息,还是有另一种方式来获取我所追求的内容?
coldfusion monitoring error-logging front-controller coldfusion-9