Seraph is a framework for writing handlers for Mongrel2 in PHP.
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.
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();
Seraph is licensed under the MIT license and is copyright (c) 2011 Sam Smith. See the LICENSE file for full copyright and license information.