Download the PHP package lizzyman04/file-router without Composer
On this page you can find all versions of the php package lizzyman04/file-router. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download lizzyman04/file-router
More information about lizzyman04/file-router
Files in lizzyman04/file-router
Package file-router
Short Description Next.js-style file-based routing for PHP. Zero dependencies, framework-agnostic.
License MIT
Homepage https://github.com/lizzyman04/file-router
Informations about the package file-router
file-router
Next.js-style file-based routing for PHP. The directory structure is the route table — no separate route file to keep in sync. Zero runtime dependencies, framework-agnostic, PHP 8.1+.
Extracted from Fluxor so it can be used standalone or dropped into any stack.
Install
Routing conventions
| File on disk | URL pattern | Params |
|---|---|---|
index.php |
/ |
— |
about.php |
/about |
— |
users/[id].php |
/users/{id} |
id |
posts/[id]/comments.php |
/posts/{id}/comments |
id |
files/[...slug].php |
/files/{slug:*} (catch-all) |
slug (rest of path) |
(admin)/dashboard.php |
/dashboard |
group folder stripped |
Matching is specificity-ordered: static > dynamic > catch-all, so
/users/me beats /users/[id].
Standalone usage
PSR-7
match() takes a method and a path string, so any PSR-7 request adapts in one line:
Options
Method extractors
A route file can serve several HTTP methods; how that's declared is pluggable
via the MethodExtractor interface.
FlowMethodExtractor(default) — readsFlow::GET(),Flow::POST(), … declarations (Fluxor style).Flow::ANY()expands to all methods. No dependency on Fluxor; it only reads the file's text.FixedMethodExtractor— every route file serves the same fixed set of methods (e.g. you dispatch by method inside the file).- Custom — implement
MethodExtractor::extract(string $file): array.
Framework adapters
Testing
License
MIT