1. Go to this page and download the library: Download nickstuer/easy-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/ */
nickstuer / easy-router example snippets
include (__DIR__ . '/vendor/autoload.php');
use \NickStuer\EasyRouter\Route as Route;
$routeManager = new \NickStuer\EasyRouter\RouteManager();
$dispatcher = new \NickStuer\EasyRouter\Dispatcher($routeManager);
$routeManager->addRoute(new Route('get', '/', 'ControllerToCall@methodToCall'));
$routeManager->addRoute(new Route('get', '/about', 'PagesController@showAbout'));
$routeManager->addRoute(new Route('get', '/contact', 'PagesController@showContact'));
$routeManager->addRoute(new Route('get', '/profile/(abc)', 'ProfileController@showProfile'));
try {
$dispatcher->dispatch();
} catch (\NickStuer\EasyRouter\Exceptions\RouteNotFoundException $e) {
echo "Route Not Found - 404";
exit;
} catch (\NickStuer\EasyRouter\Exceptions\MethodNotAllowedException $e) {
echo "Method Not Allowed - 405";
exit;
}
$routeInfo = $dispatcher->getMatchedRoute();
/**
* It's recommended that you use a DI container to create the controller class to
* automatically insert the
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.