[ABANDONED] A framework for writing handlers for Mongrel2 in PHP
PHP
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
example
src/Seraph
tests/Seraph
LICENSE
README.markdown
composer.json
composer.lock

README.markdown

Seraph

Seraph is a framework for writing handlers for Mongrel2 in PHP.

Motivation

You've heard of Mongrel2, right? One of the many awesome features of Mongrel2 is that it supports handlers. I think of handlers as long-running applications that publish responses to requests that are pulled from a Mongrel2 server using a couple of ØMQ sockets.

I wrote Seraph because I wanted to highlight that, with the help of Mikko Koppanen's "php-zmq" PHP extension, PHP is no longer bound by the lifecycle of an Apache web server.

Hello, World

Here's the smallest "Hello, World!" application that I can write cleanly:

<?php

require_once '/path/to/seraph/autoload.php';

// App
class HelloWorldApp implements Seraph_Application_Interface
{
    public function onRequest(Seraph_Request $request, Seraph_Response $response) {
        $response->setBody('Hello, World!');
    }
}

$app = new HelloWorldApp();

// Handler
$signals = new Seraph_Signal_Collection();
$handler = new Seraph_Handler('seraph_handler_test', $signals);
$handler->registerServer('Mongrel2', 'tcp://127.0.0.1:9997', 'tcp://127.0.0.1:9996')
    ->registerApplication($app)
    ->run();

See Also

  1. The Mongrel2 Web Server Project
  2. ØMQ Community - zeromq
  3. mkoppanen/php-zmq - GitHub

License

Seraph is licensed under the MIT license and is copyright (c) 2011 Sam Smith. See the LICENSE file for full copyright and license information.