fahrradkrucken / sf-router
Simple, single-file, dependency-free PHP router.
Installs: 4
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/fahrradkrucken/sf-router
This package is auto-updated.
Last update: 2025-10-16 00:49:50 UTC
README
Info
This is the simple router, implemented in one file, that could be used
through traditional composer-dependency or through require statement.
Installation
- Through Composer: 
composer require fahrradkrucken/sf-router. - As a separate file: 
require('path/to/sf-router.php'). 
Features
Basically, it allows us to (almost) do everything we usually do with routers:
- Add GET/POST/PUT/PATCH/DELETE routes (or several request methods at once);
 - Add route groups;
 - Add callbacks to routes/route-groups as well as add before/after actions (callbacks);
 - Set custom URI and REQUEST_METHOD (as FastRoute allows us to do);
 - Set simple named params inside your route, smth like
my-api/v2/user/{user_id}/actions/{action_id}/view. 
What it can't do for you:
- Handle your route's callback;
 - Get you the GET and POST request parameters.
 
So the only thing it does is takes your URI/REQUEST_METHOD and returns correct route, based on list of routes, provided by you.
Usage
See the demo.php file inside this repo to see how to use it.