PHPackages                             serendipias/laravel-urn - 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. serendipias/laravel-urn

ActiveLibrary

serendipias/laravel-urn
=======================

Universal laravel urn identifier

0.5.0(6y ago)261[1 PRs](https://github.com/Serendipias/laravel-urn/pulls)MITPHPPHP ^7.2

Since Dec 11Pushed 1y ago2 watchersCompare

[ Source](https://github.com/Serendipias/laravel-urn)[ Packagist](https://packagist.org/packages/serendipias/laravel-urn)[ RSS](/packages/serendipias-laravel-urn/feed)WikiDiscussions master Synced yesterday

READMEChangelog (1)Dependencies (8)Versions (3)Used By (0)

Laravel Urn
===========

[](#laravel-urn)

Simple way to create urn identifiers for your laravel application, allowing a simple way to identifies resources or models a more descriptive way.

[![alt text](URN_syntax_diagram.png "urn diagram")](URN_syntax_diagram.png)

#### Installation

[](#installation)

Application can be installed by running:

```
composer require serendipias/laravel-urn
```

The application requires laravel/lumen &gt;= 6.x

#### Usage

[](#usage)

##### Register provider:

[](#register-provider)

In Laravel **config/app.php** add the urn service provider to your providers array:

```
\Serendipias\Urn\UrnServiceProvider::class,
```

if you are using Lumen you will need to register the service provider in your **bootstrap/app.php**

```
$app->register(\Serendipias\Urn\UrnServiceProvider::class);
```

##### Publishing configuration:

[](#publishing-configuration)

Publish the configuration, run the following command:

```
php artisan vendor:publish --tag=urn
```

In lumen you will need to manually copy the urn file to your config directory.

The package has 3 basic configurations that are required to work with laravel/lumen models:

- models\_namespace: Models namespace, this is use to be able to get models instances from the urn
- service: this is use to declare where the urn was created, which application is the source for the identifier
- stage: determinate if the resource was generated in production, testing, stage or unit testing.

##### Enable models to generate urns

[](#enable-models-to-generate-urns)

To allow a model to be urn identifiable the model must extend `Serendipias\Urn\Contracts\UrnIdentifiable`interface, the package provides a trait with the interface default implementations `UrnIdentifiableTrait`.

To generate urn with a model, inject or make `Serendipias\Urn\Services\UrnService::class`, from there you can encode a model, or decode an urn string, in both cases an `Serendipias\Urn\Support\Urn` is returned.

**Urn instance example:**

```
Serendipias\Urn\Support\Urn {
  -urn: "urn:laravel:local:user:1"
  -namespace: "App\Models"
  -parts: array:5 [
    0 => "urn"
    1 => "laravel"
    2 => "local"
    3 => "user"
    4 => "1"
  ]
}
```

**To encode an model:**

```
$service = app(\Serendipias\Urn\Services\UrnService::class);
$urn = $service->encode(\App\Models\User::find(1));
$urn->getUrnString(); // urn:laravel:local:user:1
```

**To decode a urn string:**

```
$service = app(\Serendipias\Urn\Services\UrnService::class);
$urn = $service->decode('urn:laravel:local:user:1');
$urn->find(); // will return User model or null if not found
```

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance32

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity43

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

Unknown

Total

1

Last Release

2344d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/0e13860f4de7e879f97d56b121d7df25603c97a0a8abb6d9f8ab3597c8d6ba87?d=identicon)[jycr753](/maintainers/jycr753)

---

Top Contributors

[![coquer](https://avatars.githubusercontent.com/u/1929689?v=4)](https://github.com/coquer "coquer (11 commits)")

---

Tags

laravellaravel-frameworkurnurn-modelURNcomposerlaravelurn-identifier

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/serendipias-laravel-urn/health.svg)

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

###  Alternatives

[laravel/tinker

Powerful REPL for the Laravel framework.

7.4k423.8M1.8k](/packages/laravel-tinker)[laravel/horizon

Dashboard and code-driven configuration for Laravel queues.

4.2k84.2M225](/packages/laravel-horizon)[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9682.1M97](/packages/roots-acorn)[dyrynda/laravel-model-uuid

This package allows you to easily work with UUIDs in your Laravel models.

4802.8M8](/packages/dyrynda-laravel-model-uuid)[laravel-zero/framework

The Laravel Zero Framework.

3371.4M369](/packages/laravel-zero-framework)[spatie/laravel-prometheus

Export Laravel metrics to Prometheus

2651.3M6](/packages/spatie-laravel-prometheus)

PHPackages © 2026

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