PHPackages                             poshtive/router - 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. poshtive/router

ActiveLaravel-package[API Development](/categories/api)

poshtive/router
===============

Convention-based route discovery for Laravel controllers using PHP attributes.

v2.0.1(1mo ago)0460[9 issues](https://github.com/poshtive/laravel-router/issues)MITPHPPHP ^8.3CI passing

Since Sep 15Pushed 1mo agoCompare

[ Source](https://github.com/poshtive/laravel-router)[ Packagist](https://packagist.org/packages/poshtive/router)[ RSS](/packages/poshtive-router/feed)WikiDiscussions master Synced 1w ago

READMEChangelogDependencies (28)Versions (9)Used By (0)

Laravel Router
==============

[](#laravel-router)

Convention-based route discovery for Laravel controllers, with PHP attributes for overrides and metadata.

Status
------

[](#status)

[![Tests](https://github.com/poshtive/laravel-router/actions/workflows/tests.yml/badge.svg?branch=master)](https://github.com/poshtive/laravel-router/actions/workflows/tests.yml)[![codecov](https://camo.githubusercontent.com/73499fc38d9a2c46599cf95fdf12c2b26f4b27f7aecae04113b859373627bc1e/68747470733a2f2f636f6465636f762e696f2f67682f706f7368746976652f6c61726176656c2d726f757465722f6272616e63682f6d61737465722f67726170682f62616467652e737667)](https://codecov.io/gh/poshtive/laravel-router)

`laravel-router` is stable.

- PHP: `^8.3`
- Laravel components: `^12.0|^13.0`
- Test coverage: PHPUnit 11 + Orchestra Testbench 10/11, with `src/` at 100% locally

Highlights
----------

[](#highlights)

- Public-method route discovery with minimal registration boilerplate
- Support for nested controller resources and model-bound parameters
- Convention-based HTTP verb resolution with optional explicit overrides
- Middleware, `where` constraints, and inheritance-aware discovery
- Strict duplicate detection and optional skipped-route reporting

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

[](#installation)

Install the package with Composer:

```
composer require poshtive/router
```

Optionally publish the configuration file:

```
php artisan vendor:publish --provider="Poshtive\Router\RouterServiceProvider" --tag="config"
```

Quick Start
-----------

[](#quick-start)

Configure route discovery in `config/router.php`:

```
'groups' => [
    'web' => [
        'paths' => [app_path('Http/Controllers')],
        'middleware' => ['web'],
    ],
],
```

Then add a controller method:

```
namespace App\Http\Controllers;

class UserController
{
    public function index() {}
}
```

This registers `GET /user` automatically after the service provider boots.

You can still define Laravel routes manually as usual.

A Complete Example
------------------

[](#a-complete-example)

Keep web and API controllers in separate directories when they use different middleware or URL prefixes. For example, configure an API group like this:

```
// config/router.php
'groups' => [
    'api' => [
        'paths' => [app_path('Http/Controllers/Api')],
        'prefix' => 'api',
        'name' => 'api.',
        'middleware' => ['api'],
    ],
],
```

Then add `app/Http/Controllers/Api/UserController.php`:

```
namespace App\Http\Controllers\Api;

use App\Models\User;
use Poshtive\Router\Attributes\Route;

class UserController
{
    public function index() {}

    public function show(User $user) {}

    #[Route(method: 'POST')]
    public function store() {}

    #[Route(method: ['PUT', 'PATCH'])]
    public function update(User $user) {}
}
```

With the default `attribute_or_get` convention, discovery registers:

MethodURIName`GET``/api/user``api.user.index``GET``/api/user/{user}/show``api.user.show``POST``/api/user/store``api.user.store``PUT`, `PATCH``/api/user/{user}/update``api.user.update`The `User $user` type hint supplies the `{user}` binding placeholder. Laravel resolves the model after the route is registered. Method names default to GET; use `#[Route(method: ...)]` or `http_methods_map` for other verbs.

Documentation
-------------

[](#documentation)

- [Getting Started](docs/getting-started.md)
- [Configuration](docs/configuration.md)
- [Route Discovery](docs/route-discovery.md)
- [Attributes](docs/attributes.md)
- [Examples](docs/examples.md)

Testing
-------

[](#testing)

Run the package test suite with:

```
composer test
```

Generate a Clover coverage report for `src/` with:

```
composer test:coverage
```

Changelog
---------

[](#changelog)

Release notes are tracked in [CHANGELOG.md](CHANGELOG.md).

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

[](#contributing)

Contributions are welcome. Please feel free to submit issues or pull requests.

License
-------

[](#license)

This package is open-sourced software licensed under the [MIT license](LICENSE).

###  Health Score

46

—

FairBetter than 92% of packages

Maintenance94

Actively maintained with recent releases

Popularity16

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity57

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 ~43 days

Recently: every ~29 days

Total

8

Last Release

32d ago

Major Versions

0.1.2 → v1.0.02026-03-25

v1.2.0 → v2.0.02026-07-12

### Community

Maintainers

![](https://www.gravatar.com/avatar/527bcf0ae9008e26511af0ccc7fc1daa73c2358c36b0a05bb573459a6c8053b7?d=identicon)[moerqal](/maintainers/moerqal)

---

Top Contributors

[![qoqn](https://avatars.githubusercontent.com/u/22430343?v=4)](https://github.com/qoqn "qoqn (61 commits)")

---

Tags

laravellaravel-packagephplaravelrouterroutingdiscoveryattributes

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StyleLaravel Pint

Type Coverage Yes

### Embed Badge

![Health badge](/badges/poshtive-router/health.svg)

```
[![Health](https://phpackages.com/badges/poshtive-router/health.svg)](https://phpackages.com/packages/poshtive-router)
```

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3345.4M354](/packages/psalm-plugin-laravel)[laravel/mcp

Rapidly build MCP servers for your Laravel applications.

79227.1M229](/packages/laravel-mcp)[illuminate/filesystem

The Illuminate Filesystem package.

16166.4M3.5k](/packages/illuminate-filesystem)[nuwave/lighthouse

A framework for serving GraphQL from Laravel

3.5k12.2M128](/packages/nuwave-lighthouse)[api-platform/laravel

API Platform support for Laravel

58190.1k21](/packages/api-platform-laravel)[laravel/folio

Page based routing for Laravel.

603658.5k37](/packages/laravel-folio)

PHPackages © 2026

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