Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

A framework for writing handlers for Mongrel2 in PHP.

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 example
Octocat-spinner-32 src
Octocat-spinner-32 tests
Octocat-spinner-32 vendor
Octocat-spinner-32 .gitmodules
Octocat-spinner-32 LICENSE
Octocat-spinner-32 README.markdown
Octocat-spinner-32 autoload.php
Octocat-spinner-32 phpunit.xml
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.

Something went wrong with that request. Please try again.