PHPackages                             lizzyman04/file-router-symfony - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. lizzyman04/file-router-symfony

ActiveSymfony-bundle[Utility &amp; Helpers](/categories/utility)

lizzyman04/file-router-symfony
==============================

Symfony adapter for lizzyman04/file-router — Next.js-style file-based routing via a custom route loader.

00PHPCI passing

Since Jun 18Pushed todayCompare

[ Source](https://github.com/lizzyman04/file-router-symfony)[ Packagist](https://packagist.org/packages/lizzyman04/file-router-symfony)[ RSS](/packages/lizzyman04-file-router-symfony/feed)WikiDiscussions main Synced today

READMEChangelogDependenciesVersions (1)Used By (0)

file-router-symfony
===================

[](#file-router-symfony)

Symfony adapter for [**lizzyman04/file-router**](https://github.com/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
------------

[](#requirements)

- PHP 8.1+
- Symfony 6.4 LTS or 7.x

Install
-------

[](#install)

```
composer require lizzyman04/file-router-symfony
```

> Until the core `lizzyman04/file-router` is published on Packagist, add its repository to your app's `composer.json`:
>
> ```
> "repositories": [
>     { "type": "vcs", "url": "https://github.com/lizzyman04/file-router" }
> ]
> ```

Wire up the loader
------------------

[](#wire-up-the-loader)

Register the loader as a service tagged `routing.loader`:

```
# config/services.yaml
services:
    FileRouter\Symfony\FileRouterLoader:
        arguments:
            $routesPath: '%kernel.project_dir%/routes/pages'
        tags: ['routing.loader']
```

Then reference it from your routing config:

```
# config/routes.yaml
file_router:
    resource: '%kernel.project_dir%/routes/pages'
    type: file_router
```

Route files
-----------

[](#route-files)

Each route file **returns a callable** and declares its HTTP methods with a `// @methods` header (defaults to `GET`):

```
// routes/pages/users/[id].php
