PHPackages                             mylesduncanking/laravel-auto-bind - 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. mylesduncanking/laravel-auto-bind

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

mylesduncanking/laravel-auto-bind
=================================

Abililty to automatically bind properties in Laravel

v2.1.0(10mo ago)052MITPHPPHP ^8.0|^8.1

Since Nov 11Pushed 10mo ago1 watchersCompare

[ Source](https://github.com/mylesduncanking/laravel-auto-bind)[ Packagist](https://packagist.org/packages/mylesduncanking/laravel-auto-bind)[ Docs](https://github.com/mylesduncanking)[ RSS](/packages/mylesduncanking-laravel-auto-bind/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (6)DependenciesVersions (7)Used By (0)

Laravel Auto Bind
=================

[](#laravel-auto-bind)

Automatically bind route parameters to controller properties — clean, Laravel-native, and zero boilerplate.

Features
--------

[](#features)

- ✅ Native route-model binding
- ✅ Reduce boilerplate in constructors
- ✅ Supports soft-deleted models
- ✅ Use custom columns (e.g. `slug`)
- ✅ Easy to drop into existing Laravel apps

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

[](#installation)

```
composer require mylesduncanking/laravel-auto-bind
```

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

[](#basic-usage)

Add the `#[AutoBindProperty]` attribute to each controller property you want to bind:

```
use MylesDuncanKing\AutoBind\AutoBindProperty;

#[AutoBindProperty]
public Client $client;
```

### Use a Custom Column

[](#use-a-custom-column)

```
#[AutoBindProperty(column: 'slug')]
public Client $client;
```

### Bind Soft Deleted Records

[](#bind-soft-deleted-records)

```
#[AutoBindProperty(withTrashed: ['restore'])]
public Client $client;
```

### Call `bind()` in Your Constructor

[](#call-bind-in-your-constructor)

```
use MylesDuncanKing\AutoBind\AutoBind;

public function __construct()
{
    AutoBind::bind($this);
}
```

**Tip:** For DRY controllers, call `AutoBind::bind($this)` in a base abstract controller and extend it.

Accessing Bound Properties
--------------------------

[](#accessing-bound-properties)

Use them like any class property:

```
public function read()
{
    echo $this->client->id;
}
```

Or inject into a view:

```
return view('clients.read', array_merge(AutoBind::bound(), compact('foo')));
```

Full Example
------------

[](#full-example)

### routes/web.php

[](#routeswebphp)

```
Route::get('clients/{client}/{tab?}', [ClientsController::class, 'read'])->name('client.read');
```

### ClientsController.php

[](#clientscontrollerphp)

```
use App\Models\Client;
use MylesDuncanKing\AutoBind\AutoBind;
use MylesDuncanKing\AutoBind\AutoBindProperty as AutoBind;

class ClientsController extends \Illuminate\Routing\Controller
{
    #[AutoBind(withTrashed: ['restore'])]
    public Client $client;

    public function __construct()
    {
        AutoBind::bind($this);
    }

    public function read($tab = 'index')
    {
        return view('clients.read', AutoBind::bound($this, compact('tab')));
    }

    public function update()
    {
        $this->client->update(
            request()->validate(['name' => ['required', 'string', 'max:40']])
        );

        return redirect()->back();
    }

    public function delete()
    {
        $this->client->delete();
        return redirect()->route('clients');
    }

    public function restore()
    {
        $this->client->restore();
        return redirect()->route('clients');
    }
}
```

Why Laravel Auto Bind?
----------------------

[](#why-laravel-auto-bind)

- ✨ Less boilerplate
- 🔁 Cleaner, focused controllers
- 🧠 No new magic — pure Laravel route binding
- 🔍 Fine-tune with soft deletes and custom columns

License
-------

[](#license)

MIT

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance54

Moderate activity, may be stable

Popularity10

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity52

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

Recently: every ~58 days

Total

6

Last Release

315d ago

Major Versions

v1.1.0 → v2.0.02024-11-26

### Community

Maintainers

![](https://www.gravatar.com/avatar/ed96372ac30dea78a6eb905add8d048ac1ff98e80fdb6e6ba42cb1c21a1abdc4?d=identicon)[mylesduncanking](/maintainers/mylesduncanking)

---

Top Contributors

[![mylesduncanking](https://avatars.githubusercontent.com/u/19204499?v=4)](https://github.com/mylesduncanking "mylesduncanking (9 commits)")

---

Tags

laravelroute model binding

### Embed Badge

![Health badge](/badges/mylesduncanking-laravel-auto-bind/health.svg)

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

###  Alternatives

[highideas/laravel-users-online

This package will provide an online users management.

203113.2k1](/packages/highideas-laravel-users-online)[stephenjude/filament-blog

Filament Blog Builder

20317.8k](/packages/stephenjude-filament-blog)[ralphjsmit/laravel-helpers

A package containing handy helpers for your Laravel-application.

13704.6k2](/packages/ralphjsmit-laravel-helpers)[datomatic/nova-detached-actions

A Laravel Nova tool to allow for placing actions in the Nova toolbar detached from the checkbox selection mechanism.

11229.2k](/packages/datomatic-nova-detached-actions)

PHPackages © 2026

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