Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/moagrius/RegexRouter
PHP class to route with regular expressions. Extremely small.
https://github.com/moagrius/RegexRouter
Last synced: about 2 months ago
JSON representation
PHP class to route with regular expressions. Extremely small.
- Host: GitHub
- URL: https://github.com/moagrius/RegexRouter
- Owner: moagrius
- License: mit
- Created: 2014-02-07T06:28:05.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2015-10-28T04:24:36.000Z (about 9 years ago)
- Last Synced: 2024-10-15T20:08:35.348Z (2 months ago)
- Language: PHP
- Size: 146 KB
- Stars: 43
- Watchers: 10
- Forks: 10
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome - moagrius/RegexRouter - PHP class to route with regular expressions. Extremely small. (PHP)
README
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)
1. include or require RegexRouter.php `require_once 'RegexRouter.php';`
1. instantiate a new instance `$router = new RegexRouter();`
1. add some routes `$router->route('/^\/some\/pattern$/', );`
1. pass it either REQUEST_URI or any string for unit testing `$router->execute($_SERVER['REQUEST_URI']);`