そのため、少しの助けを借りて、最初の mvc フレームワークをローカルで起動して実行することができました。サーバーに置いたので、運がありません。設定の問題だと思いますが、よくわかりません。
これはサーバー上でどのように見えるかの Gif ですが、これはローカルで実行しています。
リモート パスに直接アクセスしても何も表示されないのはなぜですか? すなわち:
- これは動作しません:
- http://tomcat.cit.iupui.edu/alecory/Spring-2014/CIT-31300/Assignment%202/
- 「URI」定数を「/register」に直接設定しない限り、これは、以下の注に示すように、localhost で実行したときに出力されます。
- これは機能しますが、私が望むものではなく、ヘッダーとフッターが含まれていません:
config.php
<?php
include_once 'load.php';
// Local
// define ('URL_ROOT', 'http://localhost/');
// Remote
define ('URL_ROOT', 'http://tomcat.cit.ipui.edu/alecory/Spring-2014/Assignment%202/');
// define ('URI', $_SERVER['REQUEST_URI']);
// Outputs for:
// Local = /register
// Remote = /alecory/Spring-2014/CIT-31300/Assignment%202/views/register.php
define('URI', '/register'); // <= this is where I could set it myself and
# it would reroute the URL from
# /Assignment%202/views/register.php To
# /Assignment%202/
# (only showing /Assignment%202/ in the URL)
define ('DOC_ROOT', $_SERVER['DOCUMENT_ROOT']);
// Local = /Applications/MAMP/htdocs/CIT-31300/Assignment 2
// Remote = /var/www/
?>
controller.php
<?php
/**
* Controller
*
* Description: Basically tells the system what to do and in what order
*/
class Controller
{
public $load;
public $model;
function __construct()
{
// Make
$this->load = new Load();
$this->model = new Model();
// Set the $page = current view/page
$page = ltrim(URI, '/');
// Set default page to index
if (empty($page))
{
$page = 'index';
}
// Load the Pages
if (method_exists($this, $page))
{
// die(get_include_path());
require_once DOC_ROOT . '/views/inc/header.php';
$this->$page();
require_once DOC_ROOT . '/views/inc/footer.php';
}
else
{
require_once DOC_ROOT . '/views/inc/header.php';
$this->notFound();
require_once DOC_ROOT . '/views/inc/footer.php';
}
}
// Functions to load the various views
function index()
{
// $data = $this->model->my_user_info();
$this->load->view('myview.php', $data);
}
// function header()
// {
// $this->load->view('header.php', $data);
// }
// function footer()
// {
// $this->load->view('footer.php' $data);
// }
function login()
{
$this->load->view('login.php', $data);
}
function register()
{
$this->load->view('register.php', $data);
}
function notFound()
{
die('not found');
}
}
?>