PHPackages                             aidan-casey/laravel-route-binding - 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. aidan-casey/laravel-route-binding

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

aidan-casey/laravel-route-binding
=================================

Adds Laravel route binding for non-controller objects.

v0.1.2(3y ago)020MITPHPPHP ^8.1

Since May 25Pushed 3y ago1 watchersCompare

[ Source](https://github.com/aidan-casey/laravel-route-binding)[ Packagist](https://packagist.org/packages/aidan-casey/laravel-route-binding)[ RSS](/packages/aidan-casey-laravel-route-binding/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (3)Dependencies (5)Versions (4)Used By (0)

Laravel Route Binding
=====================

[](#laravel-route-binding)

This package is heavily influenced by the default [route binding](https://github.com/laravel/framework/blob/b8be411c27ae9f0ef822dab0c1e6c48beb3e06e1/src/Illuminate/Routing/ImplicitRouteBinding.php) available in Laravel. The primary difference being that this package extracts such functionality to a utility class that may be used throughout your application.

This package also resists utilizing the Laravel container to instantiate the object (though the Laravel container is used to resolve dependencies) so that this utility may be used in a Laravel service provider without causing a recursive dependency lookup.

Install
=======

[](#install)

To install, run:

```
composer install aidan-casey/laravel-route-binding
```

Usage
=====

[](#usage)

To build a class with route parameters and return an instance of it, us the static `make` method. This method does accept an extra array of parameters if you wish to override any values.

```
use AidanCasey\Laravel\RouteBinding\Binder;

// Binds route parameters to the construct of the referenced class.
$viewModel = Binder::make(IndexViewModel::class);

// Overrides the "user" parameter.
$viewModel = Binder::make(IndexViewModel::class, [
    'user' => 2,
]);
```

To bind route parameters to a specific method of a class, use the static `call` method. You may pass either an existing class instance or a class string to this method.

```
use AidanCasey\Laravel\RouteBinding\Binder;

// Calls the "execute" method on "MyTestClass."
Binder::call(MyTestClass::class, 'execute');

// Overrides the "user" parameter.
Binder::call(MyTestClass::class, 'execute', [
    'user' => 2,
]);

// Calls the "execute" method on the existing instance.

$instance = new MyTestClass;

Binder::call($instance, 'execute');
```

Performance
===========

[](#performance)

This package does make extensive use of reflection classes. It is recommended that you bind your result to the container so this only happens once. This can be done by using the `beforeResolving` method in a Laravel service provider. For example:

```
use AidanCasey\Laravel\RouteBinding\Binder;
use Illuminate\Support\ServiceProvider;

class SomeServiceProvider extends ServiceProvider
{
    public function register(){
        $this->app->beforeResolving(MyClass::class, function ($class, $parameters, $app) {
            if ($app->has($class)) {
                return;
            }

            $app->bind($class, fn ($container) => Binder::make($class, $parameters));
        });
    }
}
```

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity49

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

Total

3

Last Release

1449d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/12047504a3135813c02230ee1e5f8cc1f16968ee4d01fd4e2e852b84e55a4fcd?d=identicon)[aidancasey](/maintainers/aidancasey)

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/aidan-casey-laravel-route-binding/health.svg)

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

###  Alternatives

[watson/active

Laravel helper for recognising the current route, controller and action

3253.6M14](/packages/watson-active)[illuminate/session

The Illuminate Session package.

9937.4M753](/packages/illuminate-session)[illuminate/pagination

The Illuminate Pagination package.

10532.5M862](/packages/illuminate-pagination)[illuminate/broadcasting

The Illuminate Broadcasting package.

7126.5M178](/packages/illuminate-broadcasting)[illuminate/redis

The Illuminate Redis package.

8314.0M314](/packages/illuminate-redis)[illuminate/cookie

The Illuminate Cookie package.

224.3M122](/packages/illuminate-cookie)

PHPackages © 2026

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