2017 © Pedro Peláez
 

library superway

New generation Php route : simply and fast !

image

thomasmrln/superway

New generation Php route : simply and fast !

  • Wednesday, June 11, 2014
  • by ThomasMrln
  • Repository
  • 1 Watchers
  • 0 Stars
  • 11 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

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();
  }

The Versions

11/06 2014

dev-master

9999999-dev https://github.com/ThomasMrln/Superway

New generation Php route : simply and fast !

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

url php route router way rewriting superway road

09/04 2014

1.0.1

1.0.1.0 https://github.com/ThomasMrln/Superway

New generation Php route : simply and fast !

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

url php route router way rewriting superway road

08/04 2014

v1.0

1.0.0.0 https://github.com/ThomasMrln/Superway

New generation Php route : simply and fast !

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

url php route router rewriting