PHP code example of thomasmrln / superway

1. Go to this page and download the library: Download thomasmrln/superway library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

thomasmrln / superway example snippets



  // Instantiate your Superway router with your templates directory
  $sw = new Superway('./templates');
  
  // Superway has 


  $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}'));


  $sw->offroad(   new Road('/404',           '/404'));


  try {
  	print $sw->drive();
  } catch (\Exception $e) {
  	print "Erreur : ".$e->getMessage();
  }