PHPackages                             nckrtl/route-maker - 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. [API Development](/categories/api)
4. /
5. nckrtl/route-maker

ActiveLibrary[API Development](/categories/api)

nckrtl/route-maker
==================

This is my package route-maker

0.3.1(1y ago)06[5 PRs](https://github.com/nckrtl/route-maker/pulls)MITPHPPHP ^8.4CI passing

Since Apr 20Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/nckrtl/route-maker)[ Packagist](https://packagist.org/packages/nckrtl/route-maker)[ Docs](https://github.com/nckrtl/route-maker)[ GitHub Sponsors](https://github.com/NckRtl)[ RSS](/packages/nckrtl-route-maker/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (13)Versions (11)Used By (0)

Route Maker
===========

[](#route-maker)

This Laravel packages lets you generate a routes file based on your public controller methods. This package works particularly well with Laravel Wayfinder, as it allows you to reference controller methods instead of just routes. Based on the method signature in your controllers we could generate a routes file, automating route management entirely.

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require nckrtl/route-maker
```

You can publish and run the migrations with:

```
php artisan vendor:publish --tag="route-maker-migrations"
php artisan migrate
```

You can publish the config file with:

```
php artisan vendor:publish --tag="route-maker-config"
```

This is the contents of the published config file:

```
return [
    'method_defaults' => [
        'GET' => ['index', 'show'],
        'POST' => ['store'],
        'PUT' => ['update'],
        'DELETE' => ['destroy'],
        'PATCH' => ['edit'],
    ],
];
```

Usage
-----

[](#usage)

Update your vite config to include an additional run command:

```
import { run } from "vite-plugin-run";

export default defineConfig({
    plugins: [
        run([
            {
                name: "route-maker",
                run: ["php", "artisan", "route-maker:make"],
                pattern: ["app/**/Http/**/*.php"],
            },
        ]),
    ],
});
```

Next, update your main routes file to include the generated routes with:

```
use NckRtl\RouteMaker\Facades\RouteMaker;

RouteMaker::routes();
```

Now you're all set. Running vite dev should nog generate the routes based on your controller methods. On file change of any controller the routes file will be regenerated.

### Route definition structure

[](#route-definition-structure)

The way routes are generated are pretty opionated. The naming convention of routes is inspired by how Laravel Wayfinder exposes routes/actions. For this controller:

```
