Package Data | |
---|---|
Maintainer Username: | jeremykenedy |
Maintainer Contact: | christoph@downsized.nl (Christoph Kempen) |
Package Create Date: | 2017-07-19 |
Package Last Update: | 2023-02-26 |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-12-15 15:08:01 |
Package Statistics | |
---|---|
Total Downloads: | 121,655 |
Monthly Downloads: | 779 |
Daily Downloads: | 2 |
Total Stars: | 22 |
Total Watchers: | 3 |
Total Forks: | 2 |
Total Open Issues: | 0 |
Laravel package to generate a UUID according to the RFC 4122 standard. UUID Versions 1, 3, 4 and 5 are supported. With MIT license.
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.
composer require jeremykenedy/uuid
config/app.php
file. composer require jeremykenedy/uuid:2.1.2
config/app.php
under aliases
with the following: 'aliases' => [
'Uuid' => jeremykenedy\Uuid\Uuid::class,
];
To quickly generate a UUID just do
Uuid::generate()
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);
$uuid = Uuid::import('d3d29d70-1d25-11e3-8591-034165a3a613');
$uuid = Uuid::generate(1);
dd($uuid->time);
$uuid = Uuid::generate(4);
dd($uuid->version);
Uuid::nsDNS
is now Uuid::NS_DNS
etc. Should be an easy fix.Laravel UUID is licensed under the MIT license for both personal and commercial products. Enjoy!