PHPackages                             florddev/laravel-auto-routing - 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. florddev/laravel-auto-routing

ActiveLibrary[Framework](/categories/framework)

florddev/laravel-auto-routing
=============================

Un package de routage automatique pour Laravel

v1.2.1(1y ago)113MITPHPPHP ^8.0

Since Sep 6Pushed 1y ago1 watchersCompare

[ Source](https://github.com/Florddev/laravel-auto-routing)[ Packagist](https://packagist.org/packages/florddev/laravel-auto-routing)[ RSS](/packages/florddev-laravel-auto-routing/feed)WikiDiscussions main Synced today

READMEChangelog (5)Dependencies (1)Versions (6)Used By (0)

Laravel Auto Routing
====================

[](#laravel-auto-routing)

Laravel Auto Routing is a package that simplifies route creation in your Laravel applications using PHP 8 attributes and intuitive naming conventions, while remaining compatible with Laravel's existing routing features.

Features
--------

[](#features)

- Automatic routing based on controller methods
- Use of PHP 8 attributes to define HTTP methods
- Automatic handling of route parameters
- Support for routes with specific HTTP methods or "any"
- Automatic route naming based on controller and method names
- Compatibility with Laravel's existing routing features (middlewares, prefixes, etc.)
- Seamless integration with Laravel's route groups
- Controller-level route configuration using attributes
- Flexible attribute options for both controller and method levels
- Ability to auto route a directory and exclude specific controllers or directories from auto-routing

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

[](#requirements)

- PHP 8.0 or higher
- Laravel 8.0 or higher

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

[](#installation)

1. Install the package via Composer:

    ```
    composer require florddev/laravel-auto-routing
    ```
2. Add the service provider to your `config/app.php` file:

    ```
    'providers' => [
        // Other service providers...
        Florddev\LaravelAutoRouting\AutoRoutingServiceProvider::class,
    ],
    ```

Basic Usage
-----------

[](#basic-usage)

In your route file (e.g., `routes/web.php`), use the `auto` method to automatically register routes for a controller:

```
Route::auto('/users', \App\Http\Controllers\UserController::class);
```

In your controller, use attributes to define HTTP methods:

```
use Florddev\LaravelAutoRouting\Attributes\HttpGet;
use Florddev\LaravelAutoRouting\Attributes\HttpPost;
use Florddev\LaravelAutoRouting\Attributes\HttpPut;
use Florddev\LaravelAutoRouting\Attributes\HttpDelete;

class UserController extends Controller
{
    #[HttpGet]
    public function index() { /* ... */ }

    #[HttpGet]
    public function show(int $id) { /* ... */ }

    #[HttpPost]
    public function store() { /* ... */ }

    #[HttpPut]
    public function update(int $id) { /* ... */ }

    #[HttpDelete]
    public function destroy(int $id) { /* ... */ }
}
```

### Generated Routes

[](#generated-routes)

Here's an example of routes generated for a basic controller:

ActionGenerated RouteHTTP MethodRoute Nameindex`/users`GET`users.index`show`/users/show/{id}`GET`users.show`store`/users/store`POST`users.store`update`/users/update/{id}`PUT`users.update`destroy`/users/destroy/{id}`DELETE`users.destroy`Note: The `index` method is automatically mapped to the root of the controller's prefix.

Advanced Usage
--------------

[](#advanced-usage)

### Adding Options

[](#adding-options)

You can add additional options such as middlewares or prefixes:

```
Route::auto('/admin/users', \App\Http\Controllers\Admin\UserController::class, [
    'middleware' => ['auth', 'admin'],
    'name' => 'admin.users.',
    'namespace' => 'Admin',
]);
```

### Optional Parameters

[](#optional-parameters)

The package automatically handles optional parameters:

```
use Florddev\LaravelAutoRouting\Attributes\HttpGet;

class ApiController extends Controller
{
    #[HttpGet]
    public function search(string $query, int $page = 1, string $sort = 'desc') { /* ... */ }
}
```

This will generate a route: `GET /api/search/{query}/{page?}/{sort?}`

### Method-Level Route Configuration

[](#method-level-route-configuration)

You can customize any valid Laravel route option using attribute parameters:

```
use Florddev\LaravelAutoRouting\Attributes\HttpGet;
use Florddev\LaravelAutoRouting\Attributes\HttpPost;

class BlogController extends Controller
{
    #[HttpGet(url: "articles", name: "list")]
    public function index() { /* ... */ }

    #[HttpGet(url: "article/{slug}", name: "view")]
    public function show(string $slug) { /* ... */ }

    #[HttpPost(url: "new-article", middleware: "auth")]
    public function create() { /* ... */ }
}
```

### Controller-Level Route Configuration

[](#controller-level-route-configuration)

You can now use the `ControllerRoute` attribute to configure routes at the controller level:

```
use Florddev\LaravelAutoRouting\Attributes\ControllerRoute;

#[ControllerRoute(prefix: 'admin', name: 'admin.', middleware: ['auth', 'admin'])]
class AdminController extends Controller
{
    // ... controller methods
}
```

This will apply any valid Laravel route option as an attribute parameter in the controller.

### Using with Laravel Route Groups

[](#using-with-laravel-route-groups)

Laravel Auto Routing works seamlessly with Laravel's route groups:

```
Route::prefix('admin')->middleware('auth')->group(function () {
    Route::auto('/users', UserController::class);
    Route::auto('/products', ProductController::class, ['middleware' => 'admin']);
});
```

### Auto-routing a directory

[](#auto-routing-a-directory)

You can generate routes for all controllers in a specific directory:

```
Route::auto('/', app_path('Http/Controllers'));
```

This will generate routes for all controllers in the `/app/Http/Controllers` directory.

When auto-routing a directory, you can exclude specific controllers or subdirectories:

```
Route::auto('/', app_path('Http/Controllers'), [
    'except' => ['/Api', 'ProfileController']
]);
```

This will generate routes for all controllers in the `/app/Http/Controllers` directory, except for `ProfileController` and any controllers in the `Api` subdirectory.

Creating Auto-Routed Controllers
--------------------------------

[](#creating-auto-routed-controllers)

You can create a new controller with auto-routing methods using the following Artisan command:

```
php artisan make:controller UserController --auto
```

This will generate a new controller with basic CRUD methods already set up with the appropriate auto-routing attributes.

If you want to create a resource controller with all resource methods and auto-routing, use both the `--resource` and `--auto` options:

```
php artisan make:controller UserController --auto --resource
```

After creating the controller, don't forget to register it in your routes file:

```
Route::auto('/users', \App\Http\Controllers\UserController::class);
```

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

[](#contributing)

Contributions are welcome! Please feel free to submit a Pull Request.

License
-------

[](#license)

This package is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).

###  Health Score

26

—

LowBetter than 41% of packages

Maintenance34

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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 ~6 days

Total

5

Last Release

640d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/107536197?v=4)[Florddev](/maintainers/Florddev)[@Florddev](https://github.com/Florddev)

---

Top Contributors

[![Florddev](https://avatars.githubusercontent.com/u/107536197?v=4)](https://github.com/Florddev "Florddev (10 commits)")

---

Tags

auto-routingbackend-developmentcontroller-based-routinglaravellaravel-packagephp8-attributesroute-generationroutingweb-developmentlaravellaravel-packageroutingphp8-attributesweb-developmentbackend-developmentroute-generationauto-routingcontroller-based-routing

### Embed Badge

![Health badge](/badges/florddev-laravel-auto-routing/health.svg)

```
[![Health](https://phpackages.com/badges/florddev-laravel-auto-routing/health.svg)](https://phpackages.com/packages/florddev-laravel-auto-routing)
```

###  Alternatives

[laravel/octane

Supercharge your Laravel application's performance.

4.0k26.6M220](/packages/laravel-octane)[unopim/unopim

UnoPim Laravel PIM

10.5k2.4k](/packages/unopim-unopim)[laravel/nightwatch

The official Laravel Nightwatch package.

36210.1M35](/packages/laravel-nightwatch)[milwad/laravel-validate

The Laravel-Validate package enhanced Laravel validation capabilities with custom rules and methods for simplified and efficient validation logic.

59646.9k1](/packages/milwad-laravel-validate)[nasirkhan/laravel-starter

A CMS like modular Laravel starter project.

1.4k2.7k](/packages/nasirkhan-laravel-starter)[ecotone/laravel

Ecotone for Laravel — CQRS, Event Sourcing, Sagas, Durable Workflows, and Outbox on top of Laravel Queue, via PHP attributes.

21318.6k3](/packages/ecotone-laravel)

PHPackages © 2026

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