Following this tutorial: http://johnsquibb.com/tutorials/mvc-framework-in-1-hour-part-one
I've got the following code:
index.php
<?php
// Define document paths
define('SERVER_ROOT', '/Applications/MAMP/Library');
define('SITE_ROOT', '/Applications/MAMP/htdocs')
// Fetch the router
require_once(SERVER_ROOT . '/controllers/' . 'router.php');
router.php
<?php
//fetch the passed request
$request = $_SERVER['QUERY_STRING'];
//parse the page request and other GET variables
$parsed = explode( '&' , $request);
//the page is the first element
$page = array_shift($parsed);
//the rest of teh array are get stateemnts, parse them out.
$getVars = array();
foreach ($parsed as $argument)
{
//split GET vars along '=' symbol to separate variable, values
list($variable, $value) = split('=' , $argument);
$getVars[$variable] = $value;
}
//this is a test, and we will be removing it later
print "the page you requested is '$page'";
print '<br/>';
$vars = print_r($getVars, TRUE);
print "The following GET Vards we passed to the page:<pre>".$vars."</pre>";
punch in this url:
http://localhost/MVC_test/index.php?news&article=howtobuildaframework
I get this error:
HTTP Error 500 (Internal Server Error): An unexpected condition was encountered while the server was attempting to fulfill the request.
My MAMP home pages says my doc root is: /Applications/MAMP/htdocs
and my server root is: /Applications/MAMP/Library
Last, the path to the index file is: /Applications/MAMP/htdocs/MVC_test/index.php
What am I doing wrong?
First of all you have syntax error in your index.php, you forgot to put a semicolon on fourth line, so change code from
// Define document paths
define('SERVER_ROOT', '/Applications/MAMP/Library');
define('SITE_ROOT', '/Applications/MAMP/htdocs')
to this
// Define document paths
define('SERVER_ROOT', '/Applications/MAMP/Library');
define('SITE_ROOT', '/Applications/MAMP/htdocs');
Secondly loooks like you are not defining the above two variables with correct path make sure the SERVER_ROOT and SITE_ROOT are correct, for me SITE_ROOT should be something like
define('SITE_ROOT', '/Applications/MAMP/htdocs/MVC_test');