jeudi 3 septembre 2015

Front controller pattern - is router a front controller?

I'm trying to understand how a Front Controller should look like. From Wikipedia,

The Front Controller pattern is a software design pattern listed in several pattern catalogs. The pattern relates to the design of web applications. It "provides a centralized entry point for handling requests."

So, is the code below that handles routes in Slim a front controller?

$app = new \Slim\Slim();
$app->get('/books/:id', function ($id) use ($app) {

    // Get all books or one book.
    $bookModel = new ...
    $bookController = new ...

    $app->render('myTemplate.php', array('id' => $id, ...));
});

$app->run();

Aucun commentaire:

Enregistrer un commentaire