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

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

abdelhamiderrahmouni/self-healing-urls
======================================

v0.1.0(7mo ago)07MITPHPPHP ^8.1|^8.2|^8.3

Since Sep 26Pushed 7mo agoCompare

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

READMEChangelogDependencies (4)Versions (2)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.

> See the Original package at: [lukeraymonddowning/self-healing-urls](https://github.com/lukeraymonddowning/self-healing-urls)
>
> I forked it to use it with my laravel 12 projects.

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

[](#installation)

The package can be installed via Composer:

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

```

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

```
use AbdelhamidErrahmouni\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 AbdelhamidErrahmouni\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

31

—

LowBetter than 68% of packages

Maintenance62

Regular maintenance activity

Popularity4

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity40

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 77.4% 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

Unknown

Total

1

Last Release

229d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/745a0575996f5a3dcb6b8e177e5f37e610d83906028a1e99aa2ec3213a281027?d=identicon)[abdelhamiderrahmouni](/maintainers/abdelhamiderrahmouni)

---

Top Contributors

[![lukeraymonddowning](https://avatars.githubusercontent.com/u/12202279?v=4)](https://github.com/lukeraymonddowning "lukeraymonddowning (24 commits)")[![imanghafoori1](https://avatars.githubusercontent.com/u/6961695?v=4)](https://github.com/imanghafoori1 "imanghafoori1 (2 commits)")[![abdelhamiderrahmouni](https://avatars.githubusercontent.com/u/26693672?v=4)](https://github.com/abdelhamiderrahmouni "abdelhamiderrahmouni (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)")[![alexjustesen](https://avatars.githubusercontent.com/u/1144087?v=4)](https://github.com/alexjustesen "alexjustesen (1 commits)")

###  Code Quality

TestsPest

Code StyleLaravel Pint

### Embed Badge

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

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

###  Alternatives

[wireui/wireui

TallStack components

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

An elegantly crafted functional API for Laravel Livewire.

4195.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)
