PHPackages                             awtechs/laravel-public-ulid - 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. awtechs/laravel-public-ulid

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

awtechs/laravel-public-ulid
===========================

Binary ULID public identifiers for Laravel models

v1.0.1(2mo ago)02MITPHPPHP ^8.2

Since Feb 27Pushed 2mo agoCompare

[ Source](https://github.com/Lordeagle4/Laravel-Public-Ulid)[ Packagist](https://packagist.org/packages/awtechs/laravel-public-ulid)[ RSS](/packages/awtechs-laravel-public-ulid/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (3)Versions (4)Used By (0)

Laravel Public ULID
===================

[](#laravel-public-ulid)

Binary ULID public identifiers for Laravel models.

This package stores ULIDs in a compact 16-byte binary column, casts them to their canonical Base32 string form, and makes them suitable for public routes.

Requirements
------------

[](#requirements)

- PHP 8.2+
- Laravel 12+
- `symfony/uid` 7+

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

[](#installation)

```
composer require awtechs/laravel-public-ulid
```

Quick Start
-----------

[](#quick-start)

1. Add the schema macro in a migration:

```
Schema::table('users', function (Blueprint $table) {
    $table->publicUlid();
});
```

2. Add the trait to your model:

```
use Awtechs\PublicUlid\Concerns\HasPublicUlid;

final class User extends Model
{
    use HasPublicUlid;
}
```

Now `public_id` is automatically created as a ULID, stored as binary, and used for route model binding.

How It Works
------------

[](#how-it-works)

- **Binary storage:** `public_id` is a 16-byte binary column.
- **Cast:** `public_id` is cast to a Base32 ULID string via `BinaryUlidCast`.
- **Auto-generation:** on `creating`, if `public_id` is missing, a ULID is set.
- **Route key:** `getRouteKeyName()` returns `public_id`.

Casting
-------

[](#casting)

If you need to customize or reuse the cast directly:

```
use Awtechs\PublicUlid\Casts\BinaryUlidCast;

protected $casts = [
    'public_id' => BinaryUlidCast::class,
];
```

Validation Rule
---------------

[](#validation-rule)

```
use Awtechs\PublicUlid\Rules\ValidUlid;

request()->validate([
    'public_id' => ['required', new ValidUlid()],
]);
```

Console Command
---------------

[](#console-command)

Decode ULID details from the CLI:

```
php artisan ulid:inspect 01HZX9J4P7VWH2T0R0X6Q8N5E3
```

Testing Helpers
---------------

[](#testing-helpers)

```
use Awtechs\PublicUlid\Testing\AssertsUlids;
use Awtechs\PublicUlid\Testing\GeneratesUlids;

final class ExampleTest extends TestCase
{
    use AssertsUlids;
    use GeneratesUlids;

    public function test_ulid_helpers(): void
    {
        $ulid = $this->newUlid();
        $this->assertValidUlid($ulid);
    }
}
```

Add the Faker provider if you need ULIDs in factories:

```
use Awtechs\PublicUlid\Testing\Faker\PublicUlidProvider;

$faker->addProvider(new PublicUlidProvider($faker));
$faker->ulid();
```

Notes
-----

[](#notes)

- The column name is `public_id` by design.
- ULIDs are stored in binary, but are exposed as Base32 strings in PHP.

License
-------

[](#license)

MIT

###  Health Score

37

—

LowBetter than 83% of packages

Maintenance86

Actively maintained with recent releases

Popularity2

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity48

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

Total

2

Last Release

73d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/769d9c1fd3d565550249efb62c16c19719ed46b89271bb5f5c3385c6192304c3?d=identicon)[Lordeagle4](/maintainers/Lordeagle4)

---

Top Contributors

[![Lordeagle4](https://avatars.githubusercontent.com/u/18239064?v=4)](https://github.com/Lordeagle4 "Lordeagle4 (3 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/awtechs-laravel-public-ulid/health.svg)

```
[![Health](https://phpackages.com/badges/awtechs-laravel-public-ulid/health.svg)](https://phpackages.com/packages/awtechs-laravel-public-ulid)
```

###  Alternatives

[barryvdh/laravel-ide-helper

Laravel IDE Helper, generates correct PHPDocs for all Facade classes, to improve auto-completion.

14.9k123.0M687](/packages/barryvdh-laravel-ide-helper)[illuminate/pipeline

The Illuminate Pipeline package.

9446.6M213](/packages/illuminate-pipeline)[illuminate/pagination

The Illuminate Pagination package.

10532.5M862](/packages/illuminate-pagination)[spatie/laravel-pjax

A pjax middleware for Laravel 5

513371.8k11](/packages/spatie-laravel-pjax)[spatie/laravel-mix-preload

Add preload and prefetch links based your Mix manifest

169176.0k2](/packages/spatie-laravel-mix-preload)[illuminate/cookie

The Illuminate Cookie package.

224.3M122](/packages/illuminate-cookie)

PHPackages © 2026

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