The 140 Characters Webapp Challenge

Twitto

A web framework in a tweet

require __DIR__.'/c.php';
if (!is_callable($c = @$_GET['c'] ?: function() { echo 'Woah!'; }))
  throw new Exception('Error');
$c();
    

What is Twitto?

Twitto is the fastest PHP web framework, and the first to use the newest features of PHP 5.3 — see "Why PHP 5.3?" below.

Packed in less than 140 characters, it fits in a tweet.

Despite its size, Twitto is bundled with a default controller, is E_STRICT compliant, and generates an error if you try to access a controller that does not exist.

Published in 2009 by Fabien Potencier, Twitto is in the Public Domain. Tweet me if you find a bug!

Installation

Save the PHP code above in a twitto.php file somewhere under your web root directory.

Usage

By convention, Twitto looks for controllers in the c.php file under the same directory as the Twitto file.

Here is the classic "Hello World!" done with Twitto:

<?php
 
// c.php
function hello_world()
{
  echo 'Hello World!';
}
    

The "Hello World!" controller is now accessible at /twitto.php?c=hello_world.

If you use Apache with mod_rewrite enabled, add the following rules to your .htaccess to enjoy clean URLs (/hello_world):

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ twitto.php?c=$1 [L]
    

Why PHP 5.3?

Twitto uses several new features available as of PHP 5.3:

» TWITTO IS NOT SECURE, DON'T USE IT FOR YOUR NEXT WEBSITE «

Do you like Twitto?

If you like Twitto, you will also probably like Twittee, the Dependency Injection Container that fits in a tweet!