PHPackages                             lukeraymonddowning/self-healing-urls - 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. lukeraymonddowning/self-healing-urls

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

lukeraymonddowning/self-healing-urls
====================================

v0.7.0(3mo ago)16715.9k—5.6%19MITPHPPHP ^8.1|^8.2

Since Nov 25Pushed 3mo ago1 watchersCompare

[ Source](https://github.com/lukeraymonddowning/self-healing-urls)[ Packagist](https://packagist.org/packages/lukeraymonddowning/self-healing-urls)[ RSS](/packages/lukeraymonddowning-self-healing-urls/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (4)Versions (11)Used By (0)

Self Healing URLs
=================

[](#self-healing-urls)

Self Healing URLs is a simple Laravel package inspired by [this video from Aaron Francis](https://www.youtube.com/watch?v=a6lnfyES-LA&t=554s).

It allows you to mark Eloquent models as self-healing so that the URLs generated for said models can include an SEO friendly slug whilst not breaking should the slug alter in any way.

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

[](#installation)

The package can be installed via Composer:

```
composer require lukeraymonddowning/self-healing-urls

```

Once installed, add the `HasSelfHealingUrls` trait to any Eloquent model:

```
use Lukeraymonddowning\SelfHealingUrls\Concerns\HasSelfHealingUrls;

class Post extends Model
{
    use HasSelfHealingUrls;
}
```

If your model has a column named `slug`, you're all set. Otherwise, define a `$slug` property on your model to inform the package which column to use instead:

```
use Lukeraymonddowning\SelfHealingUrls\Concerns\HasSelfHealingUrls;

class Post extends Model
{
    use HasSelfHealingUrls;

    protected $slug = 'title';
}
```

Don't worry if your "slug" isn't URL friendly; the package will take care of formatting it for you. In fact, it doesn't even have to be unique because the defined unique identifier for your model will also be included at the end.

Limitations
-----------

[](#limitations)

By default, the package requires that your unique identifier (such as the `id` or `uuid` column) not have any `-` characters. You can implement your own `IdentifierHandler` as detailed in the next section.

Unless you implement a custom `Rerouter`, the package requires that you have defined names to the routes you want to use with self healing URLs.

Using a custom `IdentifierHandler`
----------------------------------

[](#using-a-custom-identifierhandler)

If you need to customize how a slug is joined to a model identifier (which by default is just a hyphen), you can create your own class implementing `IdentifierHandler` and register it in the register method of your `AppServiceProvider`.

Here is an example using an `_` instead of a hyphen:

```
class UnderscoreIdentifierHandler implements IdentifierHandler
{
    public function joinToSlug(string $slug, string|int $identifier): string
    {
        return "{$slug}_{$identifier}";
    }

    public function separateFromSlug(string $value): string
    {
        return Str::afterLast($value, '_');
    }
}
```

Register the custom handler in your `AppServiceProvider` like so:

```
class AppServiceProvider extends ServiceProvider
{
    public function register(): void
    {
        $this->app->singleton(IdentifierHandler::class, UnderscoreIdentifierHandler::class);
    }
}
```

Attributions
------------

[](#attributions)

Without [Aaron's video](https://www.youtube.com/watch?v=a6lnfyES-LA&t=554s), I wouldn't have even thought about this, so props to him. Go watch the video.

###  Health Score

50

—

FairBetter than 96% of packages

Maintenance78

Regular maintenance activity

Popularity43

Moderate usage in the ecosystem

Community18

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 78.1% 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 ~87 days

Recently: every ~184 days

Total

10

Last Release

116d ago

PHP version history (2 changes)v0.1.0PHP ^8.1

v0.5.0PHP ^8.1|^8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/139db346fa173a79481af05b0455e2e8ad7d2ab594c7f53bde3522a3dfeeaf25?d=identicon)[96downlu](/maintainers/96downlu)

---

Top Contributors

[![lukeraymonddowning](https://avatars.githubusercontent.com/u/12202279?v=4)](https://github.com/lukeraymonddowning "lukeraymonddowning (25 commits)")[![imanghafoori1](https://avatars.githubusercontent.com/u/6961695?v=4)](https://github.com/imanghafoori1 "imanghafoori1 (2 commits)")[![alexjustesen](https://avatars.githubusercontent.com/u/1144087?v=4)](https://github.com/alexjustesen "alexjustesen (1 commits)")[![Lakshan-Madushanka](https://avatars.githubusercontent.com/u/47297673?v=4)](https://github.com/Lakshan-Madushanka "Lakshan-Madushanka (1 commits)")[![YonkoSam](https://avatars.githubusercontent.com/u/161728760?v=4)](https://github.com/YonkoSam "YonkoSam (1 commits)")[![ju-gow](https://avatars.githubusercontent.com/u/5887244?v=4)](https://github.com/ju-gow "ju-gow (1 commits)")[![fxnm](https://avatars.githubusercontent.com/u/47592197?v=4)](https://github.com/fxnm "fxnm (1 commits)")

###  Code Quality

TestsPest

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/lukeraymonddowning-self-healing-urls/health.svg)

```
[![Health](https://phpackages.com/badges/lukeraymonddowning-self-healing-urls/health.svg)](https://phpackages.com/packages/lukeraymonddowning-self-healing-urls)
```

###  Alternatives

[wireui/wireui

TallStack components

1.8k1.3M16](/packages/wireui-wireui)[livewire/volt

An elegantly crafted functional API for Laravel Livewire.

4205.3M84](/packages/livewire-volt)[ramonrietdijk/livewire-tables

Dynamic tables for models with Laravel Livewire

21147.4k](/packages/ramonrietdijk-livewire-tables)

PHPackages © 2026

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