Ada*_*han 8 php model-view-controller
好吧,我想我正把自己推向远方,我正在自己的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
}
}
} ?>
Run Code Online (Sandbox Code Playgroud)
好的,当你看到我的前置控制器时,所以我知道它失败了,我只是在我几乎完成了我的项目后发现失败,特别是当我需要做www.someurl.com/?$getuser或www.someurl.com/myname时或者用户.
无论如何我的问题是我们什么时候真的需要PHP的MVC?
我正在看facebook等
他们仍然使用?this=blablaget,所以他们不是MVC,是吗?无论如何,我仍然很困惑Facebook 没有它的www.facebook.com/myname.(htaccess?)
如果他们不使用MVC那么我们什么时候才真正需要呢?
注意 :
我已经阅读了很多关于何时使用MVC的帖子,但是我没有在我的问题中找到一个,如果有,请发表评论,以便我可以阅读:)
非常感谢.
小智 5
我相信你在MVC和RESTful URL方案之间感到困惑(http://en.wikipedia.org/wiki/Representational_State_Transfer#RESTful_web_services).
MVC只是一种将实体和模块分开的编码模式.与GUI模板中的应用程序逻辑类似,而URL模式则完全不同.URL只是用于访问Web资源.像CodeIgnitor这样的MVC框架仍然可以为你提供"丑陋"的URL,如果你不使用.htaccess
| 归档时间: |
|
| 查看次数: |
3987 次 |
| 最近记录: |