PHPackages                             hardimpactdev/waymaker - 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. [Framework](/categories/framework)
4. /
5. hardimpactdev/waymaker

ActiveLibrary[Framework](/categories/framework)

hardimpactdev/waymaker
======================

Attribute-based route generation for Laravel - automatically generate routes from controller method attributes

v0.2.4(1mo ago)01.5k↓48.9%[5 PRs](https://github.com/hardimpactdev/waymaker/pulls)MITPHPPHP ^8.4CI passing

Since Oct 20Pushed 1mo agoCompare

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

READMEChangelog (7)Dependencies (26)Versions (14)Used By (0)

Waymaker
========

[](#waymaker)

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 hardimpactdev/waymaker
```

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

[](#requirements)

- PHP 8.4+
- Laravel 10, 11, or 12
- [vite-plugin-run](https://www.npmjs.com/package/vite-plugin-run) (for automatic route generation during development)

Install the vite plugin:

```
npm install -D vite-plugin-run
```

Usage
-----

[](#usage)

Update your vite config to include an additional run command:

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

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

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

```
use HardImpact\Waymaker\Facades\Waymaker;

Waymaker::routes();
```

Now you're all set. Running vite dev should now 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.

**Important:** As of version 2.0, explicit route attributes are required on all controller methods that should generate routes. Methods without route attributes will be ignored.

For this controller:

```
