Sinatra clone in PHP
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


Update: I finished everything that I had planned to do... So, unless someone else finds this project interesting, I believe that I am done working on it for now. Mainly because there are better/more-mature projects out there and I hate creating web frameworks in a serious manner without proper justification and "just for fun" isn't a good enough reason to clutter the PHP ecosystem.

If the name of this project isn't enough to let you know what it is, this is a Sinatra clone in PHP. Currently this is not a serious project, just a little something for me to try and learn a little more about PHP.

My background is mainly in Ruby and I have a strong love for Sinatra. So, I'm taking about the task to implement the basic feature-set that is present in Sinatra. Mainly the minimalistic route matching and hooks that Sinatra exposes for whipping up dandy little web-apps/api's very quickly.

Getting Started

A simple hello-world example in good 'ole Sinatra fashion:

# index.php
require 'pinatra.php';

Pinatra::get('/hi', function () { return 'Hello World!'; });
php -S

Before hooks:

// before everything, set a custom header
Pinatra::before('*', function () { header("MyApp: v${version}"); });

// before user's view their profile, force an update of
// their stream (silly example)
Pinatra::before('/user-profile/:id', function($id) {

After hooks:

// update site's hit-counter (also silly, but you get the point right?)
Pinatra::after('*', function () {


This little framework is only compatible with PHP v5.4.x since it was just for fun and I don't care about any sort of backwards compatability.

On the Calendar

The items that I will be adding/implementing next are (roughly) as follows:

  • Parametric URIs (variables actually passed to the handler functions)
  • Refactoring of handle_request function
  • Configuration blocks
  • Testing before and after hooks (working)
  • POST functionality
  • PUT functionality
  • DELETE functionality
  • HEAD functionality


If you actually like the sound of what I plan to do and would like to take it a little further, feel free to send me an email at or just send me a pull-request! :-]