Screen shot

Frank Sinatra was the Chairman of cool. Some fourteen years after his death, the crooner is still imitated.

Just like its namesake, Sinatra, the class Ruby web application DSL still inspires all sorts of projects from Sammy.js to Padrino to Denied.

Slim, a PHP5 project from Josh Lockhart is the latest project to cover the classics.

Setup

To get started, just require the script and call init

<?php
require('slim/Slim.php');
Slim::init();
?>

Routing

Slim supports the familiar Sinatra-style routes for all four HTTP verbs:

Slim::get('/books/:id', function ($id) {
    //Do something
});

Slim::post('/books', function () {
    //Do something
});

Slim::put('/books/:id', function ($id) {
    //Do something
});

Slim::delete('/books/:id', function ($id) {
    //Do something
});

Middleware and callbacks

Slim also allows you to run code before and after your actions:

Slim::before(function () {
    //Do something
});


Slim::after(function () {
    //Do something
});

Templating

Slim supports a variety of templates including Smarty and Twig.

[Source on GitHub] [Hompage]


Have comments? Send a tweet to @TheChangelog on Twitter.

Subscribe to The Changelog Weekly – our weekly email covering everything that hits our open source radar.