PHPackages                             lizzyman04/file-router-laravel - 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-laravel

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

lizzyman04/file-router-laravel
==============================

Laravel adapter for lizzyman04/file-router — Next.js-style file-based routing inside Laravel.

00PHPCI passing

Since Jun 18Pushed todayCompare

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

READMEChangelogDependenciesVersions (1)Used By (0)

file-router-laravel
===================

[](#file-router-laravel)

Laravel adapter for [**lizzyman04/file-router**](https://github.com/lizzyman04/file-router) — Next.js-style **file-based routing** inside a Laravel app. The directory structure becomes the route table; routes are registered as native Laravel routes, so they coexist with `routes/web.php` / `routes/api.php` and inherit Laravel's middleware, container, and route caching.

Dispatch is **fully deferred to Laravel's router** — this package only resolves which file handles a URL.

Requirements
------------

[](#requirements)

- PHP 8.2+
- Laravel 11 or 12

Install
-------

[](#install)

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

> 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" }
> ]
> ```

Publish the config:

```
php artisan vendor:publish --tag=file-router-config
```

```
// config/file-router.php
return [
    'routes_path' => base_path('routes/pages'), // directory scanned for routes
    'prefix'      => '',                         // e.g. 'api' to serve under /api/*
    'middleware'  => ['web'],                    // middleware applied to all routes
    'cache_dir'   => null,                       // e.g. storage_path('framework/cache/file-router')
];
```

The service provider is auto-discovered.

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
