Proposal for "HTTP_SimpleController"

» Metadata » Status
  • Status: Proposed
» Description

Sometimes we do not need to install a sophisticated framework. We just want a controller that handles user requests in a simple way. This is what SimpleController does.

For example:

<?php

$c = new SimpleController();
$c->on("start", function () use (&$db) {
    // this is a good place to initialize variables
    $db = new Database("dbname", "username", "xxx");
});
$c->on("get", function () use (&$username) {
    // this is a good place to initialize HTML forms
    $username = "<please enter your username here>";
});
$c->on("post", function () use (&$db, $username, $password) {
    // this is a good place to perform database operations
   $db->addUser($username, $password);
});
$c->on("end", function () use (&$db) {
    // this is a good place to close resources
    $db->close();
});

// triggers the events 'start', 'get' or 'post' and 'end'
$c->exec();
?>
» Dependencies » Links
» Timeline » Changelog
  • First Draft: 2014-02-14
  • Proposal: 2014-02-15
  • Call for Votes: 1970-01-01
  • Voting Extended: 1970-01-01