dhotson/kelpie

A little web server in PHP.

dev-master 2013-05-20 16:07 UTC

This package is not auto-updated.

Last update: 2024-11-05 03:40:37 UTC


README

A little web server in PHP.

Installation

You'll need the httpparser extension, it's a PHP extension for the C http parser from the mongrel web server:

* http://github.com/dhotson/httpparser-php

Kelpie can be installed with composer.

Add this to your composr.json:

"dhotson/kelpie": "dev-master"

Usage

A simple web application:

class HelloWorldApp
{
  public function __invoke($env)
  {
    return array(
      200,
      array("Content-Type" => "text/plain"),
      array("Hello World")
    );
  }
}

The interface is basically the same as Ruby's Rack:

To start the server:

require_once 'vendor/autoload.php';
$server = new \Kelpie\Server('0.0.0.0', 8000);
$server->start(new HelloWorldApp());

Credits

This little project is inspired by the Thin web server and the Rack web server interface.

A lot of the classes are a direct port of Ruby classes in Thin and Rack. I can't claim much credit in writing them.

Thanks go to the guys who created Thin and Rack:

The http parser is from Mongrel http://mongrel.rubyforge.org by Zed Shaw. Mongrel Web Server (Mongrel) is copyrighted free software by Zed A. Shaw You can redistribute it and/or modify it under either the terms of the GPL.