1. Go to this page and download the library: Download webhoanhao/simple-router 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/ */
webhoanhao / simple-router example snippets
// code in: ./public/index.php
// Require the router class
project)
pp namespace (change namespace to match your project)
use App\Controllers\HomeController;
// Add your routes
Route::add('/', HomeController::class,'index','index-route-name');
Route::add('/hello', HomeController::class,'hello','hello-route-name');
Route::add('/product-detail', ProductController::class,'detail','product-detail');
// ....
// Run the router
Route::run();
// code in: ./public/index.php
// Autoload files using composer
Use app namespace (change namespace to match your project)
use App\Controllers\HomeController;
// Add your routes
Route::add('/', HomeController::class,'index','index-route-name');
Route::add('/hello', HomeController::class,'hello','hello-route-name');
Route::add('/product-detail', ProductController::class,'detail','product-detail');
// ....
// Run the router
Route::run();