Mongrel2 PHP stuff
Pull request Compare This branch is 25 commits ahead, 3 commits behind winks:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

m2php-extended (working name)



This framework was designed to extend m2php with commonly needed functionality (such as route handling) in the simplest and fastest way possible. Ideally, this framework should be small enough that any developer can read through the entire codebase in under an hour.


See example/hello_world/hello.php for the latest version, as I might not be the most reliable at updating the readme.

require "../framework/server.php";
$config = array
    'uuid' => '82209006-86FF-4982-B5EA-D1E29E55D481',
    'sub_addr' => 'tcp://',
    'pub_addr' => 'tcp://',

    'routes' => array
        '#/(.*)#' => 'default',

    'handlers' => array
        'default' => array('DefaultController', 'default_action'),

class DefaultController
    function default_action($req)
        $req->reply_http("Hello, World!"); 

$server = new Server($config);



A route is a regular expression that points to a handler. When a regular expression matches the URI, the corresponding handler is called.


A handler points to a function in a class. When a handler is called, an instance of that class is created, and the corresponding function within it is called.


The session represents all of the data associated with the user. Abstract class "Session" handles all of the basic adding/removing data and cookie management. FilesystemSession extends Session and adds basic disk I/O. For an example of sessions, see examples/session_demo


An empowering, simple, and fast async handler is built in to this framework. This means that a single instance of the application can handle multiple requests from multiple users concurrently. This is particularly useful in long polling. See examples/async_hello_world. For a much more complex example, see examples/long_polling_chat