Superway
Superway is a PHP route allowing to forget your .htaccess and others way to route your urls., (*1)
Easy to "install" and launch. Superway was created to simplify the web developper work., (*2)
Usage
Intanciation
<?php
// Instantiate your Superway router with your templates directory
$sw = new Superway('./templates');
// Superway has require to know the extension of file used
$sw->extension = 'php'; // Others with tpl, html, and more
Add road
Create your routes by adding roads., (*3)
Road is composed of :
* the path of the file
* the pattern of the URL, (*4)
The power of Superway is the infinite integration of variables into the url, and the possibility of get this variables in your template, with her name., (*5)
<?php
$sw->add_road( new Road('/home', '/'));
$sw->add_road( new Road('/blog/blog', '/blog/'));
$sw->add_road( new Road('/blog/blog', '/blog/search/{query}'));
$sw->add_road( new Road('/blog/blog', '/blog/category/{id}'));
$sw->add_road( new Road('/blog/article', '/blog/article/{date}/{id}_{title}'));
Add an offroad
In case where Superway foundn't a route, it takes you back in the offroad Road, which is required., (*6)
<?php
$sw->offroad( new Road('/404', '/404'));
Use variables
To use your variables passed in the pattern, you have just to call them with their name., (*7)
For example, the pattern '/blog/article', with this url : 'http://your_url.com/blog/article/2014-04/112_title-of-your-article/' leads the use of $date (== 2014-04), $id (== 112) and $title (==title-of-your-article), (*8)
Take the wheel and drive !
To drive your roads, you have juste to launch this code and wait result..., (*9)
<?php
try {
print $sw->drive();
} catch (\Exception $e) {
print "Erreur : ".$e->getMessage();
}