Skip to content

ujanko/Siesta

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Siesta

Siesta is a simple PHP routing class. It allows you to map HTTP requests to user-defined functions in a RESTful manner.

  • Respond to different HTTP request types (GET, POST, PUT, PATCH, DELETE)
  • Follow RESTful patterns, e.g. GET user/123/status
  • Match against integers or strings

Setup

Like most routers, requests will all go through an index.php file. You will have to be able to rewrite the URL (to remove the index.php). This can be achieved with an .htaccess file on Apache systems:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . index.php [L]

Include the Siesta.php file in your index page and set the routes you would like to respond to:

require "Siesta.php";

$siesta = new Siesta();

// Respond to a home page request
$siesta->respond("GET", "/", function() {
	echo "Root path get";
});

// Get a person by id, but only if an integer is supplied
$siesta->respond("GET", "/person/(int:id)", function($id) {
	echo "You found person " . $id;
});

About

A micro PHP router, ready to REST

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • PHP 100.0%