Skip to content

RemySd/simple-router

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

A simple php router to match with your url's

Packagist Version PHP from Packagist

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]

About

A simple php router to match with your url's

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages