Example #1
0
    /**
     * Setting up custom Request object
     */
    $di->set('request', function () {
        return new RestRequest();
    });
    /**
     * Setting up custom Dispatcher
     */
    $di->set('dispatcher', function () {
        return new RestDispatcher();
    });
    /**
     * Setting up router and mounting AppRouter
     */
    $di->set('router', function () {
        $router = new Router(false);
        $router->removeExtraSlashes(true);
        $router->notFound(array('controller' => 'error404'));
        $router->mount(new AppRouter());
        return $router;
    });
    /**
     * Run the application
     */
    $app = new Application($di);
    $app->useImplicitView(false);
    $app->handle()->send();
} catch (Exception $e) {
    echo 'Uncaught Exception: ' . get_class($e) . $e->getMessage();
}