1. Go to this page and download the library: Download tdw/routing 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/ */
tdw / routing example snippets
$router = new \Tdw\Routing\Router();
$router->addGET(new \Tdw\Routing\Route('/', function (){
echo 'Home page';
}, 'home'));
class ArticleAction
{
/**
* Route GET
*/
public function index()
{
//
}
/**
* Route POST
*/
public function save()
{
//
}
}
$router->addGET(new \Tdw\Routing\Route('/articles', 'ArticleAction@index', 'article.index'));
$router->addPOST(new \Tdw\Routing\Route('/articles/save', 'ArticleAction@save', 'article.save'));
$route = (new \Tdw\Routing\Route('/article/{slug}/{id}', function () {
//
}, 'articles.show'))
->addRule('slug', new \Tdw\Routing\Rule\Slug())
->addRule('id', new \Tdw\Routing\Rule\Id());
$router->addGET($route);