Looking to hire Laravel developers? Try LaraJobs

laravel-guid maintained by tankfairies

Description
Laravel GUID Generator
Author
Last update
2024/12/02 21:23 (dev-dependabot/composer/symfony/var-dumper-7.2.0)
License
Downloads
1 375
Tags

Comments
comments powered by Disqus

Latest Stable Version Total Downloads Latest Unstable Version License Build Status

Laravel GUID

This Laravel package is useful for creating globally unique identifiers (GUID).

Installation

Install with Composer:

composer require tankfairies/laravel-guid

Usage

There are four GUID types available. GUID Version: -

    GuidInterface::UUID_TIME      -> Time based UUID        (version 1)
    GuidInterface::UUID_NAME_MD5  -> Name based (MD5) UUID  (version 3)
    GuidInterface::UUID_RANDOM    -> Random UUID            (version 4)
    GuidInterface::UUID_NAME_SHA1 -> Name based (SHA1) UUID (version 5)

All the GUIDs can be generated in one of three formats String, binary and byte. GUID format: -

    GuidInterface::FMT_STRING
    GuidInterface::FMT_BINARY
    GuidInterface::FMT_BYTE

Laravel

Register the package service provider in config/app.php file.

'providers' => [
    Tankfairies\LaravelGuid\GuidServiceProvider::class,
]

Create GUID

This will generate a random GUID

echo "GUID: " . guid(); // example output: 2b23924f-0eaa-4133-848e-7ce1edeca8c9

The guid function has four parameters: -

guid(version, format, salt, namespace)

The salt needs to be at least 6 characters long and is only required for a UUID_TIME. It can also be optionally used for UUID_NAME_MD5 and UUID_NAME_SHA1.

UUID_NAME_MD5 and UUID_NAME_SHA1 require the namespace parameter to be filled.

Copyright and license

The tankfairies/laravel-guid library is Copyright (c) 2019 Tankfairies (https://tankfairies.com) and licensed for use under the MIT License (MIT).