PHP class to route with regular expressions. Extremely small. Follows every conceivable best-practice - SRP, SoC, DI, IoC, bfft...
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.
- make sure you're sending all requests to a front controller (either through apache conf directly or htaccess)
- include or require RegexRouter.php
- instantiate a new instance
$router = new RegexRouter();
- add some routes
- pass it either REQUEST_URI or any string for unit testing