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

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

rotrer/uuid
===========

Clone of webpatser/uuid fixed for Laravel 5.2. Version 2.2.1

2.2.3(5y ago)0107MITPHPPHP &gt;=5.3.0

Since Apr 7Pushed 1y ago1 watchersCompare

[ Source](https://github.com/rotrer/laravel-uuid-2.2.1-by-webpatser)[ Packagist](https://packagist.org/packages/rotrer/uuid)[ Docs](https://github.com/rotrer/laravel-uuid-2.2.1-by-webpatser)[ RSS](/packages/rotrer-uuid/feed)WikiDiscussions main Synced 1w ago

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

Laravel Uuid
============

[](#laravel-uuid)

[![Total Downloads](https://camo.githubusercontent.com/2286476a1bfbab7d5c26214a30a0b95c5237b6c333f3a84a5bab62c3ed2b90a5/68747470733a2f2f706f7365722e707567782e6f72672f7765627061747365722f6c61726176656c2d757569642f646f776e6c6f6164732e737667)](https://packagist.org/packages/webpatser/laravel-uuid)[![Build Status](https://camo.githubusercontent.com/1c476fe37642aa9faa2672346bb1ea0848322c47c6bcff203c77b8ac01d92375/68747470733a2f2f7365637572652e7472617669732d63692e6f72672f7765627061747365722f6c61726176656c2d757569642e706e673f6272616e63683d6d6173746572)](http://travis-ci.org/webpatser/laravel-uuid)[![Latest Stable Version](https://camo.githubusercontent.com/d213868259ce504fe65ad5ce4c03ff48f8f790fa4c1b9aff161414b13938c595/68747470733a2f2f706f7365722e707567782e6f72672f7765627061747365722f6c61726176656c2d757569642f762f737461626c652e737667)](https://packagist.org/packages/webpatser/laravel-uuid)

Laravel package to generate and to validate a universally unique identifier (UUID) according to the RFC 4122 standard. Support for version 1, 3, 4 and 5 UUIDs are built-in.

Since Laravel `4.*` and `5.*` both rely on either `OpenSSL` or `Mcrypt`, the pseudo random byte generator now tries to use one of them. If both cannot be used (not a Laravel project?), the 'less random' `mt_rand()` function is used.

Laravel 5.5?
------------

[](#laravel-55)

Use laravel-uuid [version 3.0 ](https://github.com/webpatser/laravel-uuid)

What's new in 2.\*
------------------

[](#whats-new-in-2)

Laravel Uuid is now fully PSR-2, just like Laravel 5.1. Not that much has changed except for UPPERCASING the constants used in Laravel Uuid. Meaning `Uuid::nsDNS` is now `Uuid::NS_DNS` etc. Should be an easy fix.

For the 1.\* branch check the docs [here](https://github.com/webpatser/laravel-uuid/tree/1.5)

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

[](#installation)

Add `webpatser/laravel-uuid` to `composer.json`.

```
"webpatser/laravel-uuid": "^2.0"
```

Run `composer update` to pull down the latest version of Laravel UUID.

Or install it directly from the command line using

```
composer require "webpatser/laravel-uuid:2.*"
```

In Laravel 5.5 laravel-uuid will install via the new Package Discovery feature

For Laravel &lt;= 5.4: edit `config/app.php` and add the `provider` and `alias`

```
'providers' => [
    // ommited

    \Webpatser\Uuid\UuidServiceProvider::class,
]

'aliases' => [
    // ommited

    'Uuid' => Webpatser\Uuid\Uuid::class,
]
```

For Laravel 4: edit `app/config/app.php` and add the `alias`

```
'aliases' => array(
    // ommited
    'Uuid' => 'Webpatser\Uuid\Uuid',
)
```

Basic Usage
-----------

[](#basic-usage)

To quickly generate a UUID just do

```
Uuid::generate()
```

This will generate a version 1 with a random ganerated MAC address.

Advanced Usage
--------------

[](#advanced-usage)

### UUID creation

[](#uuid-creation)

Generate a version 1, time-based, UUID. You can set the optional node to the MAC address. If not supplied it will generate a random MAC address.

```
Uuid::generate(1,'00:11:22:33:44:55');
```

Generate a version 3, name-based using MD5 hashing, UUID

```
Uuid::generate(3,'test', Uuid::NS_DNS);
```

Generate a version 4, truly random, UUID

```
Uuid::generate(4);
```

Generate a version 5, name-based using SHA-1 hashing, UUID

```
Uuid::generate(5,'test', Uuid::NS_DNS);
```

### Some magic features

[](#some-magic-features)

To import a UUID

```
$uuid = Uuid::import('d3d29d70-1d25-11e3-8591-034165a3a613');
```

Extract the time for a time-based UUID (version 1)

```
$uuid = Uuid::generate(1);
dd($uuid->time);
```

Extract the version of an UUID

```
$uuid = Uuid::generate(4);
dd($uuid->version);
```

Validation
----------

[](#validation)

Just use like any other Laravel validator.

`'uuid-field' => 'uuid'`

Or create a validator from scratch. In the example an Uuid object in validated. You can also validate strings `$uuid->string`, the URN `$uuid->urn` or the binary value `$uuid->bytes`

```
$uuid = Uuid::generate();
$validator = Validator::make(['uuid' => $uuid], ['uuid' => 'uuid']);
dd($validator->passes());
```

Notes
-----

[](#notes)

Full details on the UUID specification can be found [here](http://tools.ietf.org/html/rfc4122)

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance26

Infrequent updates — may be unmaintained

Popularity11

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

Every ~0 days

Total

3

Last Release

1867d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/d703581da4bfdaf5dc83c0b701049a5b593b751d387bf43f13d23a124b4cd945?d=identicon)[rotrer](/maintainers/rotrer)

---

Top Contributors

[![rotrer](https://avatars.githubusercontent.com/u/1168305?v=4)](https://github.com/rotrer "rotrer (9 commits)")

---

Tags

UUID RFC4122

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[wujunze/laravel-id-generate

Laravel package to generate and to validate a UUID according to the RFC 4122 standard. Only support for version 1, 3, 4 and 5 UUID are built-in. and generate number id, generate primary key

134.4k](/packages/wujunze-laravel-id-generate)[slexx/laravel-webp

Detect webp support in laravel framework

104.6k](/packages/slexx-laravel-webp)

PHPackages © 2026

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