PHPackages                             adnane/simple-uuid - 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. adnane/simple-uuid

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

adnane/simple-uuid
==================

a simple laravel package to generate uuid instead of auto increment ids as primary keys

v1.0.0(4y ago)140MITPHP

Since Dec 21Pushed 4y ago1 watchersCompare

[ Source](https://github.com/adnane-ka/simple-uuid)[ Packagist](https://packagist.org/packages/adnane/simple-uuid)[ RSS](/packages/adnane-simple-uuid/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)DependenciesVersions (2)Used By (0)

Simple Uuid
-----------

[](#simple-uuid)

a simple laravel package to generate uuid instead of auto incrementing ids as primary keys.

### what's even a uuid?

[](#whats-even-a-uuid)

UUID stands for Universally Unique IDentifier. as you may encounter the acronym of it GUID (Globally Unique IDentifier).

It’s a 16 bytes Worldwide unique number! And absolulty, without using any kind of central authority or any external APIS. Actually, the way it is generated, following a standardized algorithm, ensures that every UUID is unique. and kinda impossible to generate the exact same UUID as another one somewhere else in the whole world.

and generally, it's something that looks like this:

```
e0fbbbb1-446c-4a75-be2e-746f555722b2

```

### but, why do you even need to use it and not just the auto incrementing ids?

[](#but-why-do-you-even-need-to-use-it-and-not-just-the-auto-incrementing-ids)

well, it's not fair to just say that you always need to use the UUID thing istead of auto incrementing ids to index your objects in your database. but it's something cool to know the different uses of both of them and choose depending on your needs.

here are some reasons why you should use UUIDs:

- security: and definitely this is because uuids are impossible to guess, which is not like auto incrementing ids.
- concerning database scaling: Imagine you’ve been writing blog articles on two self-hosted blogging platforms. And for some reason you want to merge those two blogs into one. If you had used usual auto-incrementing IDs, you would have to re-index every blog post of the databases and update every foreign key that might point to them. But if you had used UUID as primary key, No work to do!
- local-first applications! : Let’s say I have a collaborative application. And I want to be able to work with that application, event when I’m offline. And that means creating new content that should be added to the common database. What I expect is for the application to let me create my new content, and merge it to the central shared database when I’m back online. And I expect my coworkers to be able to do the same. In this scenario, entries in the database can’t be indexed with an auto incrementing number. Because my coworkers and myself, while offline, would be creating entries with the same ID. And once back online, we would face numerous data merging issues. UUID in this case, is a marvelous solution!

### installation

[](#installation)

> Warning: This package is not installable via Composer 1.x, make sure you upgrade to Composer 2+ before trying to install it.

using `composer`:

```
composer require adnane/simple-uuid

```

the package's service provider is auto loaded so no need to add it in the providers array in `app.php` .actually, you may need to define an alias for the package's trait , in your `app.php` in the aliases array as bellow:

```
'aliases' => [
    ..
    'SimpleUuid' => Adnane\SimpleUuid\Traits\SimpleUuid::class,
```

### use

[](#use)

as this package destined for simple use you can simply just:

1. import the package's trait inside the model that you want to use uuid on:

```
use Adnane\SimpleUuid\Traits\SimpleUuid;

# or if using an alias

use SimpleUuid;
```

2. add it to the model class:

```
use Adnane\SimpleUuid\Traits\SimpleUuid;

class User extends Model
{
    use HasFactory ,SimpleUuid;
```

3. update your target migration file:

```
Schema::create('users', function (Blueprint $table) {
    $table->uuid('id')->primary();
    ..
```

4. run laravel migrations

```
php artisan migrate
```

5. store a dummy record &amp; check out stored id:

```
e0fbbbb1-446c-4a75-be2e-746f555722b2

```

6. use as foreign key

```
# comments_table
$table->uuid('user_id')->index();
$table->foreign('user_id')->references('id')->on('users');
```

### contributing

[](#contributing)

everyone is welcome :)

### credit

[](#credit)

[Adnane.Ka](https://github.com/adnane-ka/simple-uuid)

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity49

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

1605d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/32fd3105946c7423fd448a5030df5993ae5ceca855de748881f30d5a17928cb3?d=identicon)[adnanekadri](/maintainers/adnanekadri)

---

Top Contributors

[![adnane-ka](https://avatars.githubusercontent.com/u/74255401?v=4)](https://github.com/adnane-ka "adnane-ka (7 commits)")

### Embed Badge

![Health badge](/badges/adnane-simple-uuid/health.svg)

```
[![Health](https://phpackages.com/badges/adnane-simple-uuid/health.svg)](https://phpackages.com/packages/adnane-simple-uuid)
```

PHPackages © 2026

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