api.php 602 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
<?php
    $rootDirectoryPath = realpath(dirname(__FILE__));
    define ('__ROOT_DIR', $rootDirectoryPath );

    require_once(__ROOT_DIR . "/config/config.php");
    require_once(__ROOT_DIR . '/classes/AutoLoader.class.php');

    $request = Request::getCurrentRequest();
    Response::interceptEchos();

    try {
        $controller = Dispatcher::dispatch($request);
        $response = $controller->execute();
    } catch (Exception $e) {
        $log = Response::getEchos();
        $log .= " " . $e->getMessage();
        $response = Response::errorResponse($log);
    }

    $response->send();
?>