neverender / sneeze

Small php router.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

##Sneeze##

Sneeze is a simple php router.

It uses 5.4+ features such as closure object binding and short array syntax.

####Requirements#### php >= 5.4.0

####Installation####

Use Composer

####Example####

Instantiate Sneeze application:

$app = new \Sneeze\Sneeze;

Define an HTTP GET route:

$app->get('/hello/:name', function($name) {
  echo "hello $name";
});

Run it:

$app->run();

####More####

You can also define PUT, POST and DELETE HTTP routes. Since modern browsers don't support PUT and DELETE, you can fake it by doing a POST request and adding a "_METHOD" parameter like so:

<form action="/put/route/1" method="post">
    <input type="hidden" name="_METHOD" value="PUT"/>
    <!-- other stuff -->
</form>

Inside routes, you have access to $this->request, which is an associative array of the usual request variables including 'get', 'post', 'uri', 'method', 'body', etc.

####TODO####

  • Tests
  • Refactor to make it more testable

About

Small php router.

License:MIT License


Languages

Language:PHP 100.0%