New

Just launched: Vueblocks, a brand-new search engine for Vue packages! Explore Vueblocks →

poshtive/router

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

Larablocks Analysis

poshtive/router works with Laravel 12 and 13 (latest release v3.0.0, Nov 21, 2026).

Promising: maintained and up to date, meets 2 of 4 checks; not yet widely used.

  • Works with Laravel 13, the current version
  • Released in the last 12 months (Nov 21, 2026)
  • 22 downloads a month (needs 10,000)
  • 0 GitHub stars (needs 100)

State

Actively maintained
  • Last stable release: Nov 21, 2026.
  • 7 releases in the last 12 months.
  • First released: Sep 15, 2025.
  • Monthly downloads: 22, down 67% from six months ago.
  • 1 open issue on GitHub.

Data from Packagist and GitHub, checked by Larablocks on Dec 1, 2026.

Install
composer require poshtive/router
Latest Version:v3.0.0
PHP:^8.3
Laravel:12 · 13
License:MIT
Last Updated:Nov 21, 2026
Links: GitHub  ·  Packagist
Maintainer: moerqal

Laravel Router

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

Status

Tests codecov

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

  • Folders are URLs. User/PostController becomes /user/{user}/post, at any depth.
  • Laravel resource conventions. store, show, update, and destroy get the same verbs and URIs as Route::resource().
  • Method signatures are parameters. Model, string-backed enum, and scalar parameters become placeholders; singletons need no extra setup.
  • Attributes only for exceptions. #[Post], #[Middleware], #[Resource], #[Where], and a few more, each doing one job.
  • Safe base controllers. Shared CRUD actions are opt-in with #[Discoverable], so framework helpers never leak as routes.
  • Plain Laravel routes. route:cache, route:list, and Wayfinder work unchanged.
  • Fails loudly. Invalid or duplicate routes throw in local and testing; router:check gates CI.
  • Names stay as written. BukuController is /buku; pluralization is opt-in.

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

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

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\Post;

class UserController
{
    public function index() {}

    public function store() {}

    public function show(User $user) {}

    public function update(User $user) {}

    public function destroy(User $user) {}

    #[Post]
    public function ban(User $user) {}
}

Resource actions follow Laravel's resource conventions, so discovery registers:

Method URI Name
GET /api/user api.user.index
POST /api/user api.user.store
GET /api/user/{user} api.user.show
PUT, PATCH /api/user/{user} api.user.update
DELETE /api/user/{user} api.user.destroy
POST /api/user/{user}/ban api.user.ban

The User $user type hint supplies the {user} binding placeholder. Laravel resolves the model after the route is registered. Other public methods are GET actions; use verb attributes such as #[Post] for other verbs.

Documentation

Testing

Run the package test suite with:

composer test

Generate a Clover coverage report for src/ with:

composer test:coverage

Changelog

Release notes are tracked in CHANGELOG.md.

Contributing

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

License

This package is open-sourced software licensed under the MIT license.

Alternatives to poshtive/router

pollora/discovery

Find the PHP classes that carry attributes in themes, plugins and modules, and h...

30,142 1
karewan/knroute

Simple and fast PHP 8.3+ router with route attributes and caching

2,778 2

Version History

Version Released PHP Laravel License
v3.0.0 ^8.3 ^12.0|^13.0 MIT
v2.0.1 ^8.3 ^12.0|^13.0 MIT
v2.0.0 ^8.3 ^12.0|^13.0 MIT
v1.2.0 ^8.3 ^13.0 MIT
v1.1.0 ^8.3 ^13.0 MIT