Created
March 15, 2017 14:07
-
-
Save davidchc/ddb3f056fbf01369e70d6626b905ae85 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 | |
session_start(); | |
define("DIR", dirname(__FILE__)); | |
define("DS", DIRECTORY_SEPARATOR); | |
include_once DIR.DS.'App'.DS.'Loader.php'; | |
$loader = new App\Loader(); | |
$loader->register(); | |
try{ | |
$pdo = new \PDO("mysql:host=localhost;dbname=shop", "root", ""); | |
$pdo->setAttribute(\PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); | |
}catch(\Exception $e) { | |
exit($e->getMessage()); | |
} | |
$productRepository = new App\Model\Product\ProductRepositoryPDO($pdo); | |
$page = isset($_GET['page']) ? $_GET['page'] : ''; | |
$action = isset($_GET['action']) ? $_GET['action'] : 'index'; | |
switch($page){ | |
case 'cart' : | |
$sessionCart = new App\Model\Shopping\CartSession(); | |
$cart = new App\Controller\Cart($productRepository, $sessionCart); | |
call_user_func_array(array($cart, $action), array()); | |
break; | |
default : | |
$home = new App\Controller\Home($productRepository); | |
call_user_func_array(array($home, $action), array()); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment