StupidHttp

StupidHttp is the stupidest HTTP server library for PHP ever. The problem is, as far as I can tell, the only other remotely similar library available is the PEAR HTTP_Server library, which was deprecated, like, in the 16th century or something. It still works, but it’s got lots of dependencies on other PEAR packages, and PHP hipsters (yes, there is such a thing apparently) haven’t used PEAR since some time around 1972.

As a result of this, and a rather quiet winter week-end, StupidHttp was born.

Get It

StupidHttp is available from both Github and Bitbucket, and also on Packagist if you’re using Composer.

Use It

Running a development web server with StupidHttp is stupidly easy:

    $server = new StupidHttp_WebServer('/path/to/document/root', 8080);
    $server->on('GET', '/')
           ->call(function($c) { echo 'Hello from StupidHttp!'; });
    $server->onPattern('GET', '/hello/(.+)')
           ->call(function($c, $m) { echo 'Hello, ' . $m[1]; });
    $server->run();

Yes, it does exactly what you expect:

More Examples

The source code comes with several examples in the appropriately named examples directory. Run them, they are pretty self-explanatory.

Technical Details

Here’s what StupidHttp does for you:

That’s it. That’s all it does. It does not support anything else, so obviously it’s nice for running a small embedded development web server in a PHP application, but it’s absolutely not suited for anything with more than a couple of clients connected at once, let alone for being exposed to the internet or other sensitive network (I’m sure this thing is full of security holes since I haven’t made any effort in securing it in the first place).

Remember, it’s all in the name.