kelpie
A little web server in php
About
Kelpie is a web server for PHP that takes inspiration from the best bits of the Ruby web server ecosystem:
- Rack — a minimal interface between webservers and Ruby frameworks
- The Mongrel http parser — the root of Mongrel speed and security
- Thin — a fast and simple Ruby web server
Usage
Here's what a simple Kelpie application looks like:
class HelloWorld { public function call($env) { return array( 200, array("Content-Type" => "text/plain"), array("Hello World") ); } }
The call method accepts an array of CGI like environment variables and returns an array of status code, headers, and body.
To run a Kelpie app, you need to start a server:
require_once 'lib/kelpie.php'; $server = new Kelpie_Server('localhost', 8000); $server->start(new HelloWorld());
Then in your web browser visit http://localhost:8000
Installation
Get the Kelpie source code from github:
git clone https://github.com/dhotson/kelpie.git
Kelpie requires the httpparser extension. It's a PHP extension for the Mongrel http parser.
sudo aptitude install php-pear php5-dev
sudo pear channel-discover getkelpie.com/pear
sudo pear install kelpie/httpparser
Status
Kelpie is still under active development.
Use it at your own peril. ;-)
Please get in touch if you would like to contribute.
Credits
Thanks go to the people behind Rack, Thin and Mongrel. Also, a big thank you to Alexey Zakhlestin for his code review and contributions to get the httpparser php extension into decent shape.