PHPackages                             whitecube/laravel-links - 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. [Templating &amp; Views](/categories/templating)
4. /
5. whitecube/laravel-links

ActiveLibrary[Templating &amp; Views](/categories/templating)

whitecube/laravel-links
=======================

Store &amp; resolve internal URLs without having to worry about route, slug or domain changes

v0.2.0(11mo ago)21241MITPHPPHP &gt;=8.1

Since Apr 10Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/whitecube/laravel-links)[ Packagist](https://packagist.org/packages/whitecube/laravel-links)[ RSS](/packages/whitecube-laravel-links/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (2)Dependencies (4)Versions (4)Used By (0)

Links for Laravel
=================

[](#links-for-laravel)

> 🔗 No more broken internal links!
> ♻️ Changes made to route structures, model bindings, slugs, etc. are directly transposed to all URLs generated with this package ;
> 🎯 Display intuitive and exhaustive form fields for links selection ;
> 💾 Store references to simple or complex URLs where and how you want.

Laravel's routing system is great. With this package, it will become even greater! Using a simple link reference syntax, you'll be able to store and parse URLs on-the-fly and take full advantage of Laravel's routing in rich content such as CMS editors, admin interfaces and other managed configurations.

Building a content page and want to add the possibility to insert links to your application's resources (or even external!) from your admin panel? You basically have two options:

1. Store the full URL as a string and hope it won't change soon: ```
    Hi! What can I get you? We have some great [apples](https://my-application.test/store/food/fruit/organic-apples).
    Love this package? Support us and consider [sponsoring Whitecube](https://github.com/sponsors/whitecube)!

    ```
2. Store a short, immutable reference to this URL and let your application resolve its current, working URL at runtime: ```
    Hi! What can I get you? We have some great [apples](#link[products.item@216]).
    Love this package? Support us and consider [sponsoring Whitecube](#link[sponsor])!

    ```

You'll get it: the second one is probably the best. However, it can swiftly become quite complex to setup and maintain. That's why we've built a package for it.

Table of contents
-----------------

[](#table-of-contents)

1. [Installation](#installation)
2. [Usage](#usage)
3. [Registering link resolvers](#registering-link-resolvers)
4. [Editing &amp; storing link references](#editing--storing-link-references)
5. [Resolving link URLs](#resolving-link-urls)
    - [Using the `Link` instantiation methods](#using-the-link-instantiation-methods)
    - [Using the `Links` facade](#using-the-links-facade)
    - [Using the `Str` facade or `str()` helper](#using-the-str-facade-or-str-helper)
    - [Using Blade directives](#using-blade-directives)
    - [Using model attribute casting](#using-model-attribute-casting)
6. [Reporting link resolving issues](#reporting-link-resolving-issues)

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

[](#installation)

```
composer require whitecube/laravel-links
```

This package will auto-register its service provider.

Usage
-----

[](#usage)

First, you'll need to register the application's link resolvers. Link resolvers are objects used to transform immutable link references (such as `products.item@216`) into fully qualified URLs. Resolvers can handle any of your application's routes or even complex external URLs. This package ships with a few common resolvers but feel free to create your own!

A good place to start is with a Service Provider. You can use an existing one (why not the application's `RouteServiceProvider`?) or create a dedicated Provider (e.g. `LinkServiceProvider`). Then, inside the provider's `boot` method, provide a resolver definition for each link you'll need to reference:

```
use App\Models\Product;
use Whitecube\Links\Facades\Links;

public function boot()
{
    // Simple routes:
    Links::route('home');
    Links::route('about')->title('About us');
    Links::route(name: 'catalog', parameters: ['list' => 'bestselling'])->title('Popular products');

    // Group resources as an "archive":
    Links::archive('products')
        ->index(fn($link) => $link->route('products')->title('All products'))
        ->items(fn($link) => $link->route('product')
            ->model(Product::class)
            ->title(fn($product) => $product->name)
        );
}
```

Of course, your application could have more complex routing configurations that would probably be more difficult to map into link resolvers. This package offers a lot of [advanced resolver setup features](#registering-link-resolvers) that could cover your needs, but you can also extend the shipped traits or write your own resolvers.

You can now start [inserting link references](#editing--storing-link-references) and [resolving](#resolving-link-urls) them for display.

Registering link resolvers
--------------------------

[](#registering-link-resolvers)

WIP.

Editing &amp; storing link references
-------------------------------------

[](#editing--storing-link-references)

WIP.

Resolving link URLs
-------------------

[](#resolving-link-urls)

As stated above, links can be stored in many ways, depending on your use case. Here are a few common methods that should get you started.

### Using the `Link` instantiation methods

[](#using-the-link-instantiation-methods)

WIP

### Using the `Links` facade

[](#using-the-links-facade)

WIP

### Using the `Str` facade or `str()` helper

[](#using-the-str-facade-or-str-helper)

WIP

### Using Blade directives

[](#using-blade-directives)

WIP

### Using model attribute casting

[](#using-model-attribute-casting)

Beware that model attribute casting can have undesired side-effects on dedicated link editor components since they'll probably rely on the attribute's raw value (meaning "with unresolved link references") to work.

#### Casting textual content with inline link references (inline tags)

[](#casting-textual-content-with-inline-link-references-inline-tags)

The `ResolvedInlineLinkTagsString` cast is useful when a model has attributes containing editorial content with inline link references (also called "inline tags") that all need to be resolved at once.

```
use Illuminate\Database\Eloquent\Model;
use Whitecube\Links\Casts\ResolvedInlineLinkTagsString;

class Post extends Model
{
    protected $casts = [
        'content' => ResolvedInlineLinkTagsString::class,
    ];
}
```

For instance, a `content` attribute containing the following string:

```
Hello, welcome to my website! Take a look at my [woodworking skills](#link[services.item@woodworking]) or [learn more about me](#link[about]).

```

Would be cast into:

```
Hello, welcome to my website! Take a look at my [woodworking skills](https://my-shop.com/services/professional-woodworking/) or [learn more about me](https://my-shop.com/about-me/).

```

Reporting link resolving issues
-------------------------------

[](#reporting-link-resolving-issues)

WIP.

---

Development Roadmap
-------------------

[](#development-roadmap)

Links are at the base of the world wide web. This package aims to "objectify" and take inventory of a project's internal URLs, which opens a lot of possibilites for future features and updates.

- List available link resolvers ;
- Generate URLs from link references/objects ;
- Generate full list of available concrete links for selectors &amp; specialized form UI components ;
- Replace inline link references with their resolved URL value ;
- Generate URLs with `@link()` blade directive ;
- Define link resolvers directly on Laravel's routes ;
- Cast Link objects in models ;
- Report unresolvable link references ;
- Generate XML sitemaps based on the links inventory ;
- Reverse-engineer URLs to detailed Link objects ;

Need some of the unchecked features above? Or want to add items to this list? Open an issue or a PR and we'll take a look at it! But remember, if you want professional support, don't forget to sponsor us! 🤗

🔥 Sponsorships
--------------

[](#-sponsorships)

If you are reliant on this package in your production applications, consider [sponsoring us](https://github.com/sponsors/whitecube)! It is the best way to help us keep doing what we love to do: making great open source software.

Contributing
------------

[](#contributing)

Feel free to suggest changes, ask for new features or fix bugs yourself. We're sure there are still a lot of improvements that could be made, and we would be very happy to merge useful pull requests. Thanks!

Made with ❤️ for open source
----------------------------

[](#made-with-️-for-open-source)

At [Whitecube](https://www.whitecube.be) we use a lot of open source software as part of our daily work. So when we have an opportunity to give something back, we're super excited!

We hope you will enjoy this small contribution from us and would love to [hear from you](mailto:hello@whitecube.be) if you find it useful in your projects. Follow us on [Twitter](https://twitter.com/whitecube_be) for more updates!

###  Health Score

37

—

LowBetter than 83% of packages

Maintenance73

Regular maintenance activity

Popularity16

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity42

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 94.5% 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 ~428 days

Total

2

Last Release

340d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/8435657?v=4)[Whitecube](/maintainers/Whitecube)[@whitecube](https://github.com/whitecube)

---

Top Contributors

[![toonvandenbos](https://avatars.githubusercontent.com/u/5635557?v=4)](https://github.com/toonvandenbos "toonvandenbos (52 commits)")[![FlorenceRandaxhe](https://avatars.githubusercontent.com/u/43472197?v=4)](https://github.com/FlorenceRandaxhe "FlorenceRandaxhe (3 commits)")

---

Tags

urllaravellinkbladewhitecube

###  Code Quality

TestsPest

### Embed Badge

![Health badge](/badges/whitecube-laravel-links/health.svg)

```
[![Health](https://phpackages.com/badges/whitecube-laravel-links/health.svg)](https://phpackages.com/packages/whitecube-laravel-links)
```

PHPackages © 2026

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