Skip to content

Instantly share code, notes, and snippets.

@davidchc
Created June 5, 2017 15:58
Show Gist options
  • Save davidchc/3530b7288f2e4f950c944b1a92ee9008 to your computer and use it in GitHub Desktop.
Save davidchc/3530b7288f2e4f950c944b1a92ee9008 to your computer and use it in GitHub Desktop.
<?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(\PDOException $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