Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit b184d04
Showing
19 changed files
with
1,142 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1 @@ | |||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1 @@ | |||
Please visit phpblueprint.com |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,23 @@ | |||
<?php if(!defined('RUN')){exit();} | |||
|
|||
################################################## | |||
## ## | |||
## ERROR REPORTING CONFIGURATION ## | |||
## ## | |||
################################################## | |||
# | |||
# Don't forget to change the permissions on your log folder. | |||
# | |||
$config['error_reporting']['development_environment'] = true; | |||
$config['error_reporting']['log_errors'] = true; | |||
$config['error_reporting']['error_log'] = 'application/logs/errors.log'; | |||
|
|||
################################################## | |||
## ## | |||
## ROUTING CONFIGURATION ## | |||
## ## | |||
################################################## | |||
# | |||
$config['routing']['default_controller'] = 'welcome'; | |||
$config['routing']['controller_segment'] = 1; | |||
$config['routing']['method_segment'] = 2; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,13 @@ | |||
<?php if(!defined('RUN')){exit();} | |||
|
|||
################################################## | |||
## ## | |||
## DATABASE CONFIGURATION ## | |||
## ## | |||
################################################## | |||
# | |||
$config['database']['driver'] = 'mysql'; | |||
$config['database']['host'] = 'localhost'; | |||
$config['database']['db_name'] = ''; | |||
$config['database']['user_name'] = ''; | |||
$config['database']['password'] = ''; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,14 @@ | |||
<?php if(!defined('RUN')){exit();} | |||
|
|||
class Welcome_Controller extends Controller { | |||
|
|||
public function __construct() { | |||
parent::__construct(); | |||
|
|||
// This is the default controller defined in the 'application' config file. | |||
|
|||
// Load the welcome page. | |||
$data = array('page_title' => 'Welcome to PHP Blueprint'); | |||
$this->load->view('welcome', $data); | |||
} | |||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,35 @@ | |||
<?php if(!defined('RUN')){exit();} | |||
|
|||
################################################## | |||
## ## | |||
## CONFIGURATION ## | |||
## ## | |||
################################################## | |||
# | |||
class Configuration { | |||
|
|||
############################################## | |||
# | |||
# Constructor | |||
# | |||
# 10.15.2011 - JJ Ford - Initial build. | |||
# | |||
public function __construct() | |||
{ | |||
// Load all config files. | |||
$config_files = scandir(APPLICATION.DS.CONFIG); | |||
|
|||
foreach ($config_files as $config_file) { | |||
if ($config_file === '.' || $config_file === '..') {continue;} | |||
include(APPLICATION.DS.CONFIG.DS.$config_file); | |||
} | |||
|
|||
// Turn config array into objects. | |||
$config_object = make_object($config); | |||
|
|||
// Turn config into Configuration member data. | |||
foreach ($config_object as $member => $value) { | |||
$this->$member = $value; | |||
} | |||
} | |||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,28 @@ | |||
<?php if(!defined('RUN')){exit();} | |||
|
|||
################################################## | |||
## ## | |||
## CONTROLLER ## | |||
## ## | |||
################################################## | |||
# | |||
# Parent controller for application controllers. | |||
# | |||
class Controller { | |||
|
|||
protected $config; | |||
protected $load; | |||
|
|||
############################################## | |||
# | |||
# Constructor | |||
# | |||
# 10.15.2011 - JJ Ford - Initial build. | |||
# | |||
public function __construct() | |||
{ | |||
// Load the controllers Configuration and Loader objects. | |||
$this->config =& load_class('Configuration', CORE); | |||
$this->load =& load_class('Loader', CORE); | |||
} | |||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,115 @@ | |||
<?php if(!defined('RUN')){exit();} | |||
|
|||
################################################## | |||
## ## | |||
## LOADER ## | |||
## ## | |||
################################################## | |||
# | |||
class Loader { | |||
|
|||
############################################## | |||
# | |||
# Constructor | |||
# | |||
# 10.15.2011 - JJ Ford - Initial build. | |||
# | |||
public function __construct() {} | |||
|
|||
|
|||
|
|||
############################################## | |||
# | |||
# controller | |||
# | |||
# Load application controller. | |||
# | |||
# param - Name of controller. | |||
# return - Return controller if found. | |||
# | |||
# 10.15.2011 - JJ Ford - Initial build. | |||
# | |||
public function controller($name) | |||
{ | |||
$name = ucfirst(strtolower($name)); | |||
|
|||
if (file_exists(APPLICATION.DS.CONTROLLER.DS.$name.PHP)) { | |||
require_once(APPLICATION.DS.CONTROLLER.DS.$name.PHP); | |||
$name = $name.'_Controller'; | |||
return new $name(); | |||
} | |||
|
|||
// No bueno if we made it here... | |||
echo "Unable to load the following controller: " . $name; | |||
die(); | |||
} | |||
|
|||
|
|||
|
|||
############################################## | |||
# | |||
# library | |||
# | |||
# Load application library. | |||
# | |||
# param - Name of library. | |||
# return - Return library if found. | |||
# | |||
# 10.15.2011 - JJ Ford - Initial build. | |||
# | |||
public function library($name) | |||
{ | |||
return load_class($name, LIBRARY); | |||
} | |||
|
|||
|
|||
|
|||
############################################## | |||
# | |||
# model | |||
# | |||
# Load application model. | |||
# | |||
# param - Name of model. | |||
# return - Return model if found. | |||
# | |||
# 10.15.2011 - JJ Ford - Initial build. | |||
# | |||
public function model($name) | |||
{ | |||
load_class('Model', CORE); | |||
$name = ucfirst(strtolower($name)); | |||
|
|||
if (file_exists(APPLICATION.DS.MODEL.DS.$name.PHP)) { | |||
require_once(APPLICATION.DS.MODEL.DS.$name.PHP); | |||
$name = $name.'_Model'; | |||
return new $name(); | |||
} | |||
|
|||
// No bueno if we made it here... | |||
echo "Unable to load the following model: " . $name; | |||
die(); | |||
} | |||
|
|||
|
|||
|
|||
############################################## | |||
# | |||
# view | |||
# | |||
# Load application view. | |||
# | |||
# param - Name of view. | |||
# param - Associative array of data. | |||
# | |||
# 10.15.2011 - JJ Ford - Initial build. | |||
# | |||
public function view($name, $data = null) | |||
{ | |||
if($data) {extract($data);} | |||
|
|||
if (file_exists(APPLICATION.DS.VIEW.DS.$name.PHP)) { | |||
include(APPLICATION.DS.VIEW.DS.$name.PHP); | |||
} | |||
} | |||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,43 @@ | |||
<?php if(!defined('RUN')){exit();} | |||
|
|||
################################################## | |||
## ## | |||
## LOGGING ## | |||
## ## | |||
################################################## | |||
# | |||
class Logging { | |||
|
|||
private $config; | |||
|
|||
############################################## | |||
# | |||
# Constructor | |||
# | |||
# 10.15.2011 - JJ Ford - Initial build. | |||
# | |||
public function __construct() | |||
{ | |||
// Load Configuration. | |||
$this->config =& load_class('Configuration', CORE); | |||
|
|||
// Set logging. | |||
$this->set_php_error_reporting(); | |||
} | |||
|
|||
|
|||
|
|||
############################################## | |||
# | |||
# set_php_error_reporting | |||
# | |||
# 10.15.2011 - JJ Ford - Initial build. | |||
# | |||
private function set_php_error_reporting() | |||
{ | |||
ini_set('error_reporting', E_ALL); | |||
ini_set('log_errors', $this->config->error_reporting->log_errors); | |||
ini_set('error_log', $this->config->error_reporting->error_log); | |||
ini_set('display_errors', $this->config->error_reporting->development_environment); | |||
} | |||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,54 @@ | |||
<?php if(!defined('RUN')){exit();} | |||
|
|||
################################################## | |||
## ## | |||
## MODEL ## | |||
## ## | |||
################################################## | |||
# | |||
# Parent model for application controllers. | |||
# | |||
class Model { | |||
|
|||
// Database handle | |||
protected $db; | |||
|
|||
############################################## | |||
# | |||
# Constructor | |||
# | |||
# 10.15.2011 | |||
# | |||
public function __construct() | |||
{ | |||
// Load Configuration class. | |||
$this->config =& load_class('Configuration', CORE); | |||
|
|||
// Set database configuration variables. | |||
$driver = $this->config->database->driver; | |||
$host = $this->config->database->host; | |||
$dbname = $this->config->database->db_name; | |||
$user = $this->config->database->user_name; | |||
$pass = $this->config->database->password; | |||
|
|||
// Connect to database using PDO database object. | |||
try { | |||
$this->db = new PDO("$driver:host=$host;dbname=$dbname", $user, $pass); | |||
} catch(Exception $e) { | |||
echo "Database Configuration Invalid"; | |||
} | |||
} | |||
|
|||
|
|||
|
|||
############################################## | |||
# | |||
# Destructor | |||
# | |||
# 10.15.2011 - JJ Ford - Initial build. | |||
# | |||
public function __destruct() | |||
{ | |||
$this->db = null; | |||
} | |||
} |
Oops, something went wrong.