Skip to content

Severely minimal PHP routing microframework inspired by Sinatra

Notifications You must be signed in to change notification settings

gnrfan/stradlin

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Stradlin

Severely minimal PHP routing microframework inspired by Sinatra that is specially useful for prototyping RESTful APIs.

Usage example:

require_once('stradlin.php');

route('/hello/(?P<name>\w+)/?', all_verbs(), function($params) {
  $name = $params['name'];
  if (is_numeric($name)) {
    set_status_code(400); /* Bad Request */
    $doc = array(
      "status" => "error",
      "errors" => array(
        "Come on! Your name can't be numeric! Are you a clone trooper or what?"
      )
    );
  } else {
    $doc = array(
      "status" => "ok",
      "data" => array(
        "greeting" => "Hello Mr. or Mrs. $name!!! Welcome to Stradlin :)"
      )
    );
  }
  serve_json($doc, JSON_PRETTY_PRINT);
});

In order to have the clean URLs working please use the provided .htaccess file for Apache and write/include your controllers from index.php or simply adapt it to suit your needs.

By the way, PHP 5.3+ is going to be needed to run this code since it uses lambda functions and closures.

Izzy Stradlin' and Axl Rose

Speaking of controllers, this microframework should have been called 'Axl', that's a real control freak! :)

For more information please read the freaking sources and please stay tuned.

(c) 2012 - Bit Zeppelin S.A.C. - Developed by Antonio Ognio a.k.a @gnrfan

About

Severely minimal PHP routing microframework inspired by Sinatra

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • PHP 100.0%