Example #1
0
<?php

/**
 * Copyright (c) 2014 Keith Casey
 *
 * This code is designed to accompany the lynda.com video course "Design Patterns in PHP"
 *   by Keith Casey. If you've received this code without seeing the videos, go watch the
 *   videos. It will make way more sense and be more useful in general.
 */
include_once 'controllers/default_controller.php';
include_once 'controllers/number_controller.php';
include_once 'models/number_model.php';
$action = isset($_GET['a']) ? $_GET['a'] : 'index';
$module = isset($_GET['m']) ? $_GET['m'] : '';
$id = isset($_GET['id']) ? $_GET['id'] : '';
switch ($module) {
    case 'number':
        $controller = new NumberController();
        break;
    default:
        $controller = new DefaultController();
}
$controller->run($action, $id);
Example #2
0
<?php

/**
 * Copyright (c) 2014 Keith Casey.
 *
 * This code is designed to accompany the lynda.com video course "Design Patterns in PHP"
 *   by Keith Casey. If you've received this code without seeing the videos, go watch the
 *   videos. It will make way more sense and be more useful in general.
 */
require 'vendor/autoload.php';
include_once 'controllers/default_controller.php';
include_once 'controllers/number_controller.php';
include_once 'models/number_model.php';
$app = new \Slim\Slim();
$app->get('/', function () {
    include 'views/default.php';
});
$app->get('/:module(/:number)', function ($module, $number = 1) {
    switch ($module) {
        case 'number':
            $controller = new NumberController();
            break;
        default:
            $controller = new DefaultController();
    }
    $action = 'view';
    $controller->run($action, $number);
});
$app->run();
Example #3
0
<?php

/**
 * Copyright (c) 2014 Keith Casey
 *
 * This code is designed to accompany the lynda.com video course "Design Patterns in PHP"
 *   by Keith Casey. If you've received this code without seeing the videos, go watch the
 *   videos. It will make way more sense and be more useful in general.
 */
include_once 'controllers/default_controller.php';
include_once 'controllers/greeting_controller.php';
include_once 'models/greeting.php';
$action = isset($_GET['a']) ? $_GET['a'] : 'index';
$module = isset($_GET['m']) ? $_GET['m'] : '';
switch ($module) {
    case 'greeting':
        $controller = new GreetingController();
        break;
    default:
        $controller = new DefaultController();
}
$controller->run($action);