【发布时间】:2010-07-30 18:23:30
【问题描述】:
好吧,我想我把自己推到了这里,我正在自己的 MVC 中创建一个项目,即使我不知道 MVS 本身是什么,
<?php
class init
{
function __construct()
{
$this->enviroment();
$this->start();
}
function enviroment()
{
/* Required Classes */
require_once( ROOTPATH . BOOTSTRAP . REDENGINE . '/class.debug.php');
require_once( ROOTPATH . BOOTSTRAP . REDENGINE . '/class.theme.php');
require_once( ROOTPATH . BOOTSTRAP . REDENGINE . '/class.url.php');
require_once( ROOTPATH . BOOTSTRAP . REDENGINE . '/language/class.lang.php');
require_once( ROOTPATH . BOOTSTRAP . REDENGINE . '/class.sessions.php');
}
function start()
{
/* Start Classes */
$uSys = new Urlsystem;
$fragments = $uSys->getFragments();
$tSys = new ThemeSystem;
$lSys = new LanguageSystem;
$sSys = new Sessions;
/* defineing APPVIEWS & APPCONTROLLER */
define( 'APPVIEWS', '/appviews' );
define( 'APPCONTROLLER', '/appcontroller' );
if ( empty($fragments) )
{
require_once( ROOTPATH . APPCONTROLLER . '/app.home.php'); /* default app controller page */
require_once( ROOTPATH . APPVIEWS . '/view.home.php'); /* default app views page */
}
if ( !empty($fragments) )
{
// Start ENGINE
if ( !file_exists(ROOTPATH . APPCONTROLLER . '/app' . $fragments . '.php') &&
!file_exists(ROOTPATH . APPVIEWS . '/view' . $fragments. '.php')
) {
if ( file_exists(ROOTPATH . APPCONTROLLER . '/app.404.php') &&
file_exists(ROOTPATH . APPVIEWS . '/view.404.php')
) {
require ROOTPATH . APPCONTROLLER . '/app.404.php';
require ROOTPATH . APPVIEWS . '/view.404.php';
}
else {
echo "NO 404 APP || VIEW";
}
}
if ( file_exists(ROOTPATH . APPCONTROLLER . '/app' . $fragments . '.php') )
{
require ROOTPATH . APPCONTROLLER . '/app' . $fragments . '.php'; // load application
if ( file_exists(ROOTPATH . APPVIEWS . '/view' . $fragments . '.php') ) {
require ROOTPATH . APPVIEWS . '/view' . $fragments . '.php';// load view
}
}
// End ENGINE
}
}
} ?>
好的,正如你看到我的前端控制器,所以我知道它失败了,我只是在我几乎完成我的项目后才注意到我的失败,特别是当我需要做 www.someurl.com/?$getuser 或 www.someurl.com/myname 或用户。
无论如何,我的问题是我们什么时候真正需要 MVC for PHP?
我在看脸书等
他们仍然使用 ?this=blabla get 所以他们不是 MVC ,对吗?无论如何,我仍然对 facebook 如何在没有它的情况下 www.facebook.com/myname 感到困惑。 (htaccess ?)
如果他们不使用 MVC,那么我们什么时候真正需要它?
注意:
我已经阅读了很多关于何时使用 MVC 的帖子,但我没有在我的问题中找到一个,如果有请留下评论以便我阅读:)
非常感谢。
【问题讨论】:
-
希望你得到你需要的答案。
-
yup 仍然很困惑,关于在使用实用风格(旧编程风格)时使用 mvc 时,比如包含控制器视图(在一个文件中)。可能要等 2 天或更长时间:| .顺便说一句,AJ 的答案很好。只是需要一些时间。
-
谢谢。非常感谢您的赞赏。 :)
-
不是你要感谢的人:)