Thank you for the advice this is what i have so far with the framework, let me know what you think
index.php
<?php
//Load autoloader
require dirname(__FILE__).'/system/load.inc.php';
use System\Config\Config;
//Set up some configuration
Config::setBasePath(dirname(__FILE__));
system/load.inc.php
<?php
namespace System;
require_once __dir__ .'/Config/config.php';
require_once __dir__ .'/autoloader/autoloader.php';
use System\Autoloader\Autoloader;
system/Controllers/Controller.php
<?php
namespace System\Controllers;
abstract class Controller{
protected static $instance = array();
/**
*Creates and gives a new controller instance
**/
public static function Instance(){
$class = get_called_class();
if(!static::$instance[$class]){
static::$instance[$class] = new $class();
}
return static::$instance[$class];
}
}
system/Views/Views.php
<?php
namespace System\Views;
use System\Config\Config;
class Views{
/**
*Loads our view file into the browser
**/
public static function load($view,$data = array()){
$layout_path = Config::GetBasePath() . '/app/views/layout';
$view_path = Config::GetBasePath() . '/app/views';
/***Extract data from array***/
extract($data);
//Check if view exist
if(file_exists($view_path)){
require $view_path.'/'.$view.'.php';
}
}
}
system/autoloader/autoloader.php
<?php
namespace System\Autoloader\Autoloader;
use System\Config\Config;
class Autoloader{
/**
Loads a class file using our autoloader
**/
public static function ClassLoad($class){
$_class_path = Config::getBasePath() . '/libraries';
//Check if class file exist
if(file_exists($_class_path)){
require $_class_path.'/'.'.php';
}
}
}
This post has been edited by webdesigner93: 03 January 2012 - 09:42 PM