Download the PHP package pelmered/laravel-ulid without Composer
On this page you can find all versions of the php package pelmered/laravel-ulid. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download pelmered/laravel-ulid
More information about pelmered/laravel-ulid
Files in pelmered/laravel-ulid
Package laravel-ulid
Short Description Universally Unique Lexicographically Sortable Identifier(ULID) for Laravel
License MIT
Informations about the package laravel-ulid
Laravel-ULID
This package improves the ULID support in Laravel with the following features:
- Configurable prefix
- Configurable length (both time and random parts)
- Configurable formatting/case
- Configurable time source
- Configurable randomness source
- Provides a Facade for working with ULIDs
ULIDs - What and why
ULIDs are a compact, time-ordered, globally unique identifier that are used to identify resources in a way that is both human-readable and machine-readable.
For a more in-depth technical explanation, see the ULID specification
One of my personal favorite things about ULIDs is that you can double-click on them to select and copy.
Try to select and copy these IDs: u_01ARZ3NDEKTSV4RRFFQ69G5FAVY
and 4f839b45-fcca-495b-b9ed-0e365270b1c3
.
The prefixes also makes it immediately clear what kind of ID it is when you see it.
This is great when you are passing IDs around to colleagues or coworkers when debugging or working with support. The hyphens also look pretty ugly and do not have any real meaning for a human.
TODO
- [ ] Add more tests
- [ ] Add docs
- [x]
Add license - [x]
Add badges - [ ] Implement custom formatter support
Roadmap
- [ ] Migration tool for migrating an existing database with numeric or UUIDs to ULIDs. Probably as a separate suggested package.
Installation
Setup
Add the interface Ulidable
and the trait HasUlid
to your model.
Configuration
You can configure the ULID prefix, time length and random length in the model.
You probably shouldn't touch the time length unless you know what you are doing.\ The Random part could be optimized based on your needs. A low traffic application could probably use a shorter random part to optimize storage space and performance.
Usage (Work in progress)
Migrations
To create a ULID column in a migration, you can use the ulid
or modelULid
methods like this to get the correct length.
Facade
Formatting
Config
Publish the config file config/ulid.php
to your project.
Running tests
Run the test with vendor/bin/pest
or composer test
.
The test suite has some tests that require a MySQL database.
To run these tests, you need to create a .env
file in the root of the project with the following contents,
adjusted for your setup:
You can also skip the MySQL tests the tests by running vendor/bin/pest --exclude-group=mysql
.
All versions of laravel-ulid with dependencies
lewiscowles/ulid Version ^1.3.1
illuminate/support Version ^11.30|^12.0
php-static-analysis/attributes Version ^0.3.1|^0.4.0
nesbot/carbon Version ^3.8.4|^4.0
ext-bcmath Version *