PHPackages                             lassehaslev/laravel-package-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. [Utility &amp; Helpers](/categories/utility)
4. /
5. lassehaslev/laravel-package-router

ActiveLaravel-plugin[Utility &amp; Helpers](/categories/utility)

lassehaslev/laravel-package-router
==================================

0.1.2(9y ago)083

Since Dec 10Compare

[ Source](https://github.com/LasseHaslev/laravel-package-router)[ Packagist](https://packagist.org/packages/lassehaslev/laravel-package-router)[ RSS](/packages/lassehaslev-laravel-package-router/feed)WikiDiscussions Synced today

READMEChangelogDependencies (3)Versions (3)Used By (0)

lassehaslev/laravel-package-router
==================================

[](#lassehaslevlaravel-package-router)

> Your package routes made REALLY simple!

Install
-------

[](#install)

Run `composer require lassehaslev/laravel-package-router`

Usage
-----

[](#usage)

This is a [global/universal](https://github.com/LasseHaslev/UniversalObjects) object to handle your routes.

Even tough this package is made to handle routes in packages, it is no trouble using it wherever you want.

#### Register your routes

[](#register-your-routes)

Add your routes in ServiceProvider@register

```
// It is recommended that you extend the class
class MyRouter extends LasseHaslev\LaravelPackageRouter\PackageRouter {}

// Create new router
$router = MyRouter::create();

// Add route to router
$router->add( 'users.index', [
    'uri'=>'users',
    'as'=>'users.index',
    'uses'=>'Controller@index',
] )
// You can also chain add
->app( 'users.update', [
    'uri'=>'users/{user}',
    'method'=>'put',
    'uses'=>'Controller@index',
] );

->add( 'images.index', [
    'uri'=>'images',
    'uses'=>'Controller@index',
] )
->add( 'images.store', [
    'uri'=>'images',
    'method'=>'post',
    'uses'=>'Controller@store',
] )
```

#### Register routes

[](#register-routes)

Note that you can get the reference of the router only by calling `MyRouter::get()` even though you created it another place. This is because it extends [LasseHaslev\\UniversalObjects\\Object](https://github.com/LasseHaslev/UniversalObjects).

```
// Usually in your routes/web.php
$myRouter = MyRouter::get();

$myRouter->route( 'images.index' ); // "/images"
Route::group([ 'prefix'=>'backend', 'middleware'=>'auth' ], function( $router ) use ( $myRouter ) {
    $myRouter->routes( 'users' ); // "/backend/users" and "/backend/users/{user}"
    $myRouter->route( 'images.store' ); // "/backend/images"
});
```

#### Api

[](#api)

```
// Get the router
$router = MyRouter::create(); // MyRouter::get();

// Add route
$router->add( $reference, [
    'uri'=>'users',
    'method'=>'get',
    'as'=>'users.index',
    'uses'=>'Controller@index',
    // 'middleware'=>'auth', // You can add middleware if you want to
] );

// Get all routes
$router->routes(); // Set routes for users.index, images.index and images.show

// Get all routes under images namespace
$router->routes( 'images' ); // Set routes for images.index and images.show

// Get single route
$router->route( 'images.index' );
```

Development
-----------

[](#development)

```
# Install dependencies
composer install

# Install dependencies for automatic tests
yarn

# Run one time
npm run test

# Automaticly run test on changes
npm run dev
```

###  Health Score

24

—

LowBetter than 31% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community2

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

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

Total

2

Last Release

3487d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/39edaff7913420649a4d7e159faecfef8210b583f645ef2f89545f2c72b64a9b?d=identicon)[LasseHaslev](/maintainers/LasseHaslev)

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/lassehaslev-laravel-package-router/health.svg)

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

PHPackages © 2026

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