Skip to content
lafka edited this page Apr 30, 2012 · 2 revisions

What's this for?

A quick and uncluttered way to setup a structure for routing requests. Wave can be though of as a mini-toolkit with a autoloader implementation, it makes structuring multiple libraries/frameworks together an easy task and allows developers to focus on the business logic rather than trying to make the tools behave they want.

So what is this REALLY for ?

This is a nice way to turn:

<?php

switch ($_GET['page']) {
    case "home":
        // logic
        break;
    case "contact":
        // logic
        break;
    default:
       // Oh noes....
        break;
}
?>

Into this (yes that is really annotations in php.....)

<?php

/**
 * @GET /
 * @GET /home
 */
class Route extends Wave\Route\Annotated implements Wave\Route\IFace {
    public function dispatch ($uri) {
        // Home sweet home
    }
}

Getting roughly started

To install it you need to setup a webserver with PHP and make it point everything to index.php. After doing that you need to install some files:

mkdir my-src-dir && cd my-src-dir
git init
git submodule add https://[email protected]/lafka/wave.git Wave
ln -P Wave/index.php .
mkdir -p MyPackage/HelloWorld/
cat >> MyPackage/HelloWorld/Route.php <<EOF
<?php
namespace MyPackage\HelloWorld;
use Wave\Route\Iface, Wave\Route\Regex;

class Route extends Regex implements Iface {
    protected \$regex = '~/(hello|good-?day)~i';

    public function dispatch (\$uri) {
        echo "Good day to you!";
    }
}

EOF

Now go to http://your-example-host/hello and see for yourself

Clone this wiki locally