Macaw is a simple PHP router. It's super small, fast, and sexy.
Macaw is not an object, so you can just make direct operations to the class. Here's the Hello World:
Macaw::get('/', function() {
echo 'Hello world!';
});
Macaw::dispatch();
Macaw also supports lambda URIs, such as:
Macaw::get('/(:any)', function($slug) {
echo 'The slug is: ' . $slug;
});
Macaw::dispatch();
You can also make requests for HTTP methods in Macaw, so you could also do:
Macaw::get('/', function() {
echo 'I <3 GET commands!';
});
Macaw::post('/', function() {
echo 'I <3 POST commands!';
});
Macaw::dispatch();
Lastly, if there is no route defined for a certian location, you can make Macaw run a custom callback, like:
Macaw::error(function() {
echo '404 :: Not Found';
});
If you don't specify an error callback, Macaw will just echo 404
.
In order to let the server know the URI does not point to a real file, you need to use the included .htaccess file.