PHPackages                             ricventu/laravel-route-maze - 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. ricventu/laravel-route-maze

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

ricventu/laravel-route-maze
===========================

A quick and easy way to create the routes is to take advantage of the convention over configuration

v1.1.4(1y ago)0892[4 PRs](https://github.com/ricventu/laravel-route-maze/pulls)MITPHPPHP ^8.1CI passing

Since Nov 23Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/ricventu/laravel-route-maze)[ Packagist](https://packagist.org/packages/ricventu/laravel-route-maze)[ Docs](https://github.com/ricventu/laravel-route-maze)[ Fund](https://ko-fi.com/ricventu)[ RSS](/packages/ricventu-laravel-route-maze/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (8)Dependencies (13)Versions (13)Used By (0)

Convention over configuration Laravel route generator
=====================================================

[](#convention-over-configuration-laravel-route-generator)

[![Latest Version on Packagist](https://camo.githubusercontent.com/9087852c13fed805f8210976450d522f4864625ed96e878e760616ed4ebb36f3/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f72696376656e74752f6c61726176656c2d726f7574652d6d617a652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/ricventu/laravel-route-maze)[![GitHub Tests Action Status](https://camo.githubusercontent.com/084104837104af258c37d3e0ae72fa9673a117b028514e9cf76dd0afe9a0db8a/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f72696376656e74752f6c61726176656c2d726f7574652d6d617a652f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/ricventu/laravel-route-maze/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/758f8cad1cab68861076d442b020b892ccf9df4db11d151a2b0079a7c5884d41/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f72696376656e74752f6c61726176656c2d726f7574652d6d617a652f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/ricventu/laravel-route-maze/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/334fc55c86b3790e69d8f5c10548a31d35f0e5af0760a44ad24dd1a683033207/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f72696376656e74752f6c61726176656c2d726f7574652d6d617a652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/ricventu/laravel-route-maze)

A quick and easy way to auto generate routes, is to take advantage of the **convention over configuration** and **PHP attributes**.
This means that routes are automatically generated based on the directory structure of the controllers and the methods attributes.
In this way, you don't have to manually write the routes in the web.php or api.php file, but just follow some rules of file naming and organization.
Route groups are base on subdirectories of the controllers.

Let's see how to do it with a practical example.

Controller: `App/Http/Controllers/SomeCategory/ProductsController.php`

```
class ProductsController
{
    // index and __invoke defaults to GET
    public function index() {...}
    #[Get]
    public function show($id) {...}
    #[Post]
    public function store(Request $request) {...}
    #[Patch]
    public function update($id, Request $request) {...}
    #[Delete]
    public function destroy($id) {...}
}
```

To get routes simpli add the the following line to `routes/web.php`

```
    Route::maze(app_path('Http/Controllers'), 'App\\Http\\Controllers');
```

The generated routes are:

```
    Route::get('/some-category/products', 'SomeCategory\ProductsController@index')->name('some-category.products');
    Route::get('/some-category/products/show/{id}', 'SomeCategory\ProductsController@show')->name('some-category.products.show');
    Route::post('/some-category/products/store', 'SomeCategory\ProductsController@store')->name('some-category.products.store');
    Route::Patch('/some-category/products/update/{id}', 'SomeCategory\ProductsController@update')->name('some-category.products.update');
    Route::delete('/some-category/products/destroy/{id}', 'SomeCategory\ProductsController@destroy')->name('some-category.products.destroy');
```

Parameters in path
------------------

[](#parameters-in-path)

Parameters can be specified in the path naming the directory with `_param-name_`.

`Http/Controllers/_param1_/ItemsController.php`

```
class ItemsController
{
    #[Get]
    public function get($id) {...}
}
```

becomes

```
    Route::get('/{param1}/items/get/{id}', 'ItemsController@get')->name('items.get');
```

Middleware
----------

[](#middleware)

You can specify middleware group by adding a file named `middleware.php` in the controller directory.

```
return [
    'auth',
];
```

Naming conventions
------------------

[](#naming-conventions)

Uri and route name are composed of directories name, first part of the controller name (before `Controller`) and method name, all in kebab-case.

examples:

Controller nameMethod nameRoute nameRoute pathSomeProductControllershowItem($id)some.product.show-item/some-product/show-item/{id}SomeProductControllerstoreItemsome.product.store-item/some-product/store-itemSomeProductControllerupdateItem($id)some.product.update-item/some-product/update-item/{id}SomeProductControllerdestroyItem($id)some.product.destroy-item/some-product/destroy-item/{id}Disable discover for a Controller
---------------------------------

[](#disable-discover-for-a-controller)

To disable route discover for a specified crontroller, add static method `mazeDisabled` that returns `true`

In path configuration
---------------------

[](#in-path-configuration)

If in the path is present a file named `maze.php`, it will be used to configure the route group.

```
return [
];
```

KeyDescriptionDefaultignore\_path\_nameIgnore path and name in routefalsedisabledDisable discovering of the entire path```
## Installation

You can install the package via composer:

```bash
composer require ricventu/laravel-route-maze
```

Usage
-----

[](#usage)

```
    Route::maze(app_path('Http/Controllers'), 'App\\Http\\Controllers');
```

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Performance note
----------------

[](#performance-note)

In production deployment, it's recommended to cache route discovering using Laravel `route:cache` built in command

Credits
-------

[](#credits)

- [Riccardo Venturini](https://github.com/ricventu)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

40

—

FairBetter than 88% of packages

Maintenance69

Regular maintenance activity

Popularity14

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 82.7% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~62 days

Recently: every ~109 days

Total

8

Last Release

466d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/ab9a6e1dbd1cea7ad570eba962e9f4d64938b8c2f96199da62056cc60d06cb25?d=identicon)[ricventu](/maintainers/ricventu)

---

Top Contributors

[![ricventu](https://avatars.githubusercontent.com/u/3369838?v=4)](https://github.com/ricventu "ricventu (86 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (10 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (8 commits)")

---

Tags

generatorlaravelroutesricventularavel-route-maze

###  Code Quality

TestsPest

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/ricventu-laravel-route-maze/health.svg)

```
[![Health](https://phpackages.com/badges/ricventu-laravel-route-maze/health.svg)](https://phpackages.com/packages/ricventu-laravel-route-maze)
```

###  Alternatives

[guava/calendar

Adds support for vkurko/calendar to Filament PHP.

298241.0k3](/packages/guava-calendar)[tonysm/rich-text-laravel

Integrates Trix content with Laravel

46577.8k1](/packages/tonysm-rich-text-laravel)[hydrat/filament-table-layout-toggle

Filament plugin adding a toggle button to tables, allowing user to switch between Grid and Table layouts.

6292.3k1](/packages/hydrat-filament-table-layout-toggle)[tonysm/globalid-laravel

Identify app models with a URI. Inspired by the globalid gem.

45101.6k2](/packages/tonysm-globalid-laravel)[ralphjsmit/laravel-helpers

A package containing handy helpers for your Laravel-application.

13704.6k2](/packages/ralphjsmit-laravel-helpers)[spatie/laravel-screenshot

Take screenshots of web pages in Laravel apps

7615.9k2](/packages/spatie-laravel-screenshot)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
