remysd / simple-router
A simple router to match with your url's
1.3.0
2021-04-07 19:21 UTC
This package is auto-updated.
Last update: 2024-05-31 00:28:44 UTC
README
Installation
composer require remysd/simple-router
Example
require './vendor/autoload.php'; use RemySd\SimpleRouter\Router; $router = new Router(); $router->setBasePath('/simple-router'); $router->addRoute('/articles', 'article', 'all', 'article_all'); $router->addRoute('/articles/{id}', 'article', 'show', 'article_single'); $properties = $router->match($_SERVER['REQUEST_URI']); $url = $router->generate('single_article', ['id' => 3]);
Requirements
Minimun configuration required in .htaccess
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . index.php [L]