Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Mongrel2 PHP stuff

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 example
Octocat-spinner-32 framework
Octocat-spinner-32 .gitignore
Octocat-spinner-32 README.md
Octocat-spinner-32 TODO.md
README.md

m2php-extended (working name)

Requirements

Purpose

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.

Example

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://127.0.0.1:9997',
    'pub_addr' => 'tcp://127.0.0.1:9996',

    '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);
$server->run();

Basics

Routes

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

Handlers

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.

Session

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

Async

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

Something went wrong with that request. Please try again.