Skip to content

moagrius/RegexRouter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RegexRouter

PHP class to route with regular expressions. Extremely small. Follows every conceivable best-practice - SRP, SoC, DI, IoC, bfft...

Usage

The only actual code is RegexRouter.php. index.php and the .htaccess file are just demoing usage. The 3 together in a TLD will function.

Setup

  1. make sure you're sending all requests to a front controller (either through apache conf directly or htaccess)
  2. include or require RegexRouter.php require_once 'RegexRouter.php';
  3. instantiate a new instance $router = new RegexRouter();
  4. add some routes $router->route('/^\/some\/pattern$/', <closure>);
  5. pass it either REQUEST_URI or any string for unit testing $router->execute($_SERVER['REQUEST_URI']);

About

PHP class to route with regular expressions. Extremely small.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages