Created
November 19, 2015 16:15
-
-
Save TorbenKoehn/2882684c5ab51dcc2920 to your computer and use it in GitHub Desktop.
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
<?php | |
return [ | |
'db' => [ | |
'host' => 'localhost', | |
'user' => '<db_user>', | |
'password' => '<db_password>', | |
'name' => '<database_name>' | |
] | |
]; |
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
<?php render_head()?> | |
<?php render_header()?> | |
<h1>Page not found!</h1> | |
<?php render_footer()?> | |
<?php render_foot()?> |
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
<?php render_head()?> | |
<?php render_header()?> | |
<?php switch ($action) { | |
case 'index': | |
default: | |
?> | |
<h1>My Index Action!</h1> | |
<p> | |
This one occurs when you call index.php?controller=book&action=index | |
</p> | |
<?php | |
break; | |
case 'list': | |
?> | |
<h1>Book overview</h1> | |
<?php | |
$stmt = $pdo->query('SELECT * FROM `books`'); | |
?> | |
<?php foreach ($stmt as $row): ?> | |
<div class="book-row"> | |
<h1><?=$book['title']?></h1> | |
<p> | |
<?=$book['teaser']?> | |
</p> | |
</div> | |
<?php endforeach; ?> | |
<?php | |
break; | |
} | |
?> | |
<?php render_footer()?> | |
<?php render_foot()?> |
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
//Some helper functions. E.g.: | |
function render($view, array $args = null) | |
{ | |
extract($args ? $args : []); | |
include VIEW_PATH.'/'.$view.'.phtml'; | |
} | |
function render_head(array $args = null) | |
{ | |
return render('head'); | |
} | |
function render_header(array $args = null) | |
{ | |
return render('header'); | |
} | |
function render_footer(array $args = null) | |
{ | |
return render('footer'); | |
} | |
function render_foot(array $args = null) | |
{ | |
return render('foot'); | |
} | |
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
<?php | |
$pdo = new PDO('mysql:host='.$config['db']['host'].'; database='.$config['db]['name'], $config['db']['user'], $config['db']['password']); | |
//Other initialization logic maybe? |
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
<?php | |
//Loading the config | |
$config = include(__DIR__.'/config.php'); | |
//Initializing "controller" and "action" GET variables | |
$controller = isset($_GET['controller']) ? preg_replace('/[^a-z\-]/i', '', $_GET['controller']) : 'index'; | |
$action = isset($_GET['action']) ? preg_replace('/[^a-z\-]/i', '', $_GET['action']) : 'index'; | |
//Include initialization stuff and helper functions | |
include __DIR__.'/includes/init.php'; | |
include __DIR__.'/includes/functions.php'; | |
//Check if the given controller is a valid controller | |
$controllerPath = __DIR__.'/controllers/'.$controller.'.php'; | |
if (!file_exists($controllerPath)) | |
include __DIR__.'/controllers/404.php'; | |
//Include the controller (Meaning "run it") | |
include $controllerPath; |
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
<script src="jquery.js???"></script> | |
</body> | |
</html> |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<!-- Your head content --> | |
</head> | |
<body> |
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
<header> | |
<h1>My Page Header!</h1> | |
<h2>This should display on all sites</h2> | |
</header> |
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
/ | |
config.php | |
index.php | |
includes/ | |
init.php | |
functions.php | |
views/ | |
head.php | |
header.php | |
navigation.php | |
footer.php | |
foot.php | |
controllers/ | |
404.php | |
index.php | |
book.php | |
user.php |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment