Download the PHP package lizzyman04/file-router-symfony without Composer
On this page you can find all versions of the php package lizzyman04/file-router-symfony. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download lizzyman04/file-router-symfony
More information about lizzyman04/file-router-symfony
Files in lizzyman04/file-router-symfony
Package file-router-symfony
Short Description Symfony adapter for lizzyman04/file-router — Next.js-style file-based routing via a custom route loader.
License MIT
Homepage https://github.com/lizzyman04/file-router-symfony
Informations about the package file-router-symfony
file-router-symfony
Symfony adapter for lizzyman04/file-router —
Next.js-style file-based routing in Symfony via a custom route loader. The
directory structure becomes a RouteCollection, so file-based routes plug into
Symfony's routing exactly like attribute/annotation or YAML routes — same
matcher, same cache, same dispatch.
Requirements
- PHP 8.1+
- Symfony 6.4 LTS or 7.x
Install
Until the core
lizzyman04/file-routeris published on Packagist, add its repository to your app'scomposer.json:
Wire up the loader
Register the loader as a service tagged routing.loader:
Then reference it from your routing config:
Route files
Each route file returns a callable and declares its HTTP methods with a
// @methods header (defaults to GET):
The handler may return a Symfony Response (passed through) or an array/string
(normalized to a JsonResponse/Response).
Filesystem → URL
| File on disk | Symfony path | Notes |
|---|---|---|
index.php |
/ |
|
about.php |
/about |
|
users/[id].php |
/users/{id} |
$params['id'] |
posts/[id]/comments.php |
/posts/{id}/comments |
|
files/[...path].php |
/files/{path} + requirement path: .+ |
catch-all; $params['path'] is the rest |
(admin)/dashboard.php |
/dashboard |
group folder stripped |
Catch-all is resolved in the loader: [...path] becomes an ordinary Symfony
placeholder constrained to .+, so no custom matching is needed downstream.
Caching & coexistence
- The loader attaches a
DirectoryResource, so Symfony's router cache is invalidated when route files change — no double caching (leave the file-router cache off and let Symfony cache the compiled collection). - The produced routes are merged into Symfony's
RouteCollection, so they coexist with attribute/annotation and YAML routes. 404/405 are produced by Symfony's own matcher.
Testing
Tests run the loader through Symfony's real UrlMatcher and an HttpKernel
dispatch pipeline.
License
MIT
All versions of file-router-symfony with dependencies
lizzyman04/file-router Version ^1.0
symfony/config Version ^6.4|^7.0
symfony/routing Version ^6.4|^7.0
symfony/http-foundation Version ^6.4|^7.0