Class is not being recognized

My Object class is not being recognized. I have tried verifying i wrote everything correct but in my router.php gives me the following error:

Libraries:

libraries/object.php
[php]
// contain’s mtehods for all the user defined controllers
class Controller extends Object {

	public static $user_vars = array();


public function __set($name, $value){
	self::$user_vars[$name] = $value;
}

public function __get($name){
return(isset(self::$user_vars[$name])) ? self::$user_vars[$name] : null;
}

[/php]

libraries/router.php
[php]
class Map extends Object{
public static $path = null;

public static function get($route, $path) {
	self::$path = $path;
	Sammy::process($route, 'GET');
}

public static function post($route, $path) {
	self::$path = $path;
	Sammy::process($route,  'POST');
}

public static function put($route, $path) {
	self::$path = $path;
	Sammy::process($route,  'PUT');
}

public static function delete($route, $path) {
	self::$path = $path;
	Sammy::process($route,  'DELETE');
}

public static function ajax($route, $path) {
	self::$path = $path;
	Sammy::process($route,  'XMLHttpRequest');
}

public static function dispatch($format) {

// runs when find a matching route
$path = explode('#', self::$path);
$controller = $path[0];
$action = $path[1];

$class_name = ucfirst($controller) . 'Controller';
    
// include the app_controller
self::load_controller('app');

// include the matching route controller
self::load_controller($controller);

if( class_exists($class_name) ) {
  $tmp_class = new $class_name();
        
  // run the matching action
  if( is_callable(array($tmp_class, $action)) ) {
    $tmp_class->$action();
  }else
    die('The action <strong>' . $action . '</strong> could not be called from the controller <strong>' . $class_name . '</strong>');
}else
  die('The class <strong>' . $class_name . '</strong> could not be found in <pre>' . APP_PATH . 'controllers/' . $controller . '_controller.php</pre>');

   
// include the view file

// self::load_view($controller, $action, $format);

//load the layout
$layout_path=  self::get_layout($controller, $action, $format);
if( !empty($layout_path) ){
   $layout = file_get_contents($layout_path);
   
   echo $layout;
}

}
public static function load_controller($name) {
$controller_path = APP_PATH . ‘controllers/’ . $name . ‘_controller.php’;
if( file_exists($controller_path) )
include_once $controller_path;
else
die('The file ’ . $name . '_controller.php could not be found at

’ . $controller_path . ‘
’);
}

public static function load_view($controller, $action, $format) {
$view_path = APP_PATH . ‘views/’ . $controller . ‘/’ . $action . ‘.’ . $format . ‘.php’;
if( !empty($view_path) ) {
unset($controller, $action, $format);

  foreach(self::$user_vars as $var => $value ) {
    $$var = $value;
  }
  
  include_once $view_path;
}

}

public static function get_layout($controller, $action, $format){
//controller-action.format.php
$controller_action_path = APP_PATH . ‘views/layouts/’ . $controller . ‘-’ . $action . ‘.’ . $format . ‘.php’;

// controller.format.php
$controller_path = APP_PATH . 'views/layouts/' . $controller . '.' . $format . '.php';

// application.format.php
$application_path = APP_PATH . 'views/layouts/application.' . $format . '.php';

$path_to_use = null;

// find the path to use
if( file_exists($controller_action_path) )
  $path_to_use = $controller_action_path;
  
elseif( file_exists($controller_path) )
  $path_to_use = $controller_path;
  
elseif( file_exists($application_path) )
  $path_to_use = $application_path;
  
return $path_to_use;

}

}
[/php]

libraries/core.php
[php]
// contains methods for all the user defined controllers
include ‘object.php’;
include ‘controller.php’;
include ‘sammy.php’;
include ‘router.php’;

include BASE_PATH . ‘config/routes.php’;

$sammy->run()

[/php]

libraries/sammy.php
[php]
class Sammy {

public static $route_found = false;

public $uri = '';

public $segments = '';

public $method = '';

public $format = '';

public static function instance() {
	static $instance = null;

	if( $instance === null ) {
		$instance = new Sammy;
	}

	return $instance;
}

public static function run() {
	if( !static::$route_found ) {
	  $sammy = Sammy::instance();
		
	}

	ob_end_flush();
}

public static function process($route, $type) {
	$sammy = static::instance();

// Check for ajax
	if( $type == 'XMLHttpRequest' )
	  $sammy->method = isset($_SERVER['HTTP_X_REQUESTED_WITH']) ? $_SERVER['HTTP_X_REQUESTED_WITH'] : 'GET';	

	if( static::$route_found || (!preg_match('@^'.$route.'(?:\.(\w+))?$@uD', $sammy->uri, $matches) || $sammy->method != $type) ) {
		return false;
	}

// Get the extension
$extension = $matches[count($matches)-1];
$extension_test = substr($sammy->uri, -(strlen($extension)+1), (strlen($extension)+1));

if( $extension_test == '.' . $extension )
  $sammy->format = $extension;
else
  $sammy->format = 'html';

	static::$route_found = true;
	Map::dispatch($sammy->format);
}

public function __construct() {
	ob_start();
	$this->uri = $this->get_uri();
	$this->segments = explode('/', trim($this->uri, '/'));
	$this->method = $this->get_method();
}

public function segment($num) {
  $num--;

// Remove the extension
$this->segments[$num] = isset($this->segments[$num]) ? rtrim($this->segments[$num], '.' . $this->format) : null;

	return isset($this->segments[$num]) ? $this->segments[$num] : null;
}

protected function get_method() {
	return isset($_SERVER['REQUEST_METHOD']) ? $_SERVER['REQUEST_METHOD'] : 'GET';
}

protected function get_uri($prefix_slash = true) {
    if( isset($_SERVER['PATH_INFO']) ) {
        $uri = $_SERVER['PATH_INFO'];
    }elseif( isset($_SERVER['REQUEST_URI']) ) {
        $uri = $_SERVER['REQUEST_URI'];

        if( strpos($uri, $_SERVER['SCRIPT_NAME']) === 0 ) {
            $uri = substr($uri, strlen($_SERVER['SCRIPT_NAME']));
        }elseif( strpos($uri, dirname($_SERVER['SCRIPT_NAME'])) === 0 ) {
            $uri = substr($uri, strlen(dirname($_SERVER['SCRIPT_NAME'])));
        }

        // This section ensures that even on servers that require the URI to be in the query string (Nginx) a correct
        // URI is found, and also fixes the QUERY_STRING server var and $_GET array.
        if( strncmp($uri, '?/', 2) === 0 ) {
            $uri = substr($uri, 2);
        }

        $parts = preg_split('#\?#i', $uri, 2);
        $uri = $parts[0];

        if( isset($parts[1]) ) {
            $_SERVER['QUERY_STRING'] = $parts[1];
            parse_str($_SERVER['QUERY_STRING'], $_GET);
        }else {
            $_SERVER['QUERY_STRING'] = '';
            $_GET = array();
        }
        $uri = parse_url($uri, PHP_URL_PATH);
    }else {
        // Couldn't determine the URI, so just return false
        return false;
    }

    // Do some final cleaning of the URI and return it
    return ($prefix_slash ? '/' : '').str_replace(array('//', '../'), '/', trim($uri, '/'));
}

public function format($name, $callback) {
  $sammy = static::instance();
  if( !empty($sammy->format) && $name == $sammy->format )
    echo $callback($sammy);
  else
    return false;
}

}

$sammy = Sammy::instance();
[/php]

controller/app_controller.php
[php]
class AppController extends Controller{

}

[/php]

controller/welcome_controller.php
[php]
class WelcomeController extends AppController{

public function index() {
  $this->name = 'Jon';
       }

[/php]

main/index.php
[php]
// for use in development code
error_reporting(E_ALL);
define(‘BASE_PATH’, dirname(realpath(FILE)) . ‘/’);
define(‘APP_PATH’, BASE_PATH . ‘app/’);

include BASE_PATH . ‘libraries/core.php’;

[/php]

Sponsor our Newsletter | Privacy Policy | Terms of Service