https://github.com/phpgt/ulid
Unique, lexicographically sortable identifiers.
https://github.com/phpgt/ulid
Last synced: 2 months ago
JSON representation
Unique, lexicographically sortable identifiers.
- Host: GitHub
- URL: https://github.com/phpgt/ulid
- Owner: phpgt
- Created: 2022-02-04T18:29:57.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2023-10-31T17:43:01.000Z (over 2 years ago)
- Last Synced: 2025-03-07T12:08:36.867Z (over 1 year ago)
- Language: PHP
- Homepage:
- Size: 76.2 KB
- Stars: 0
- Watchers: 2
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
Awesome Lists containing this project
README
Unique, lexicographically sortable identifiers.
===============================================
Create a `new Ulid()` anywhere in your application, and you have a stringable object that can be used as the primary key in a database. Ulid strings look something like `01G2J6MYN0PGC5Q21W9C` or can be prefixed with a type like `CUSTOMER_01G2J6MYN0PGC5Q21W9C`. They are cryptographically pseudo-random, and sort so that newer Ulids compare "greater than" older Ulids.
This solves the problems exposed with working with auto-incrementing integer primary keys, which are predictable and difficult to work with in distributed databases.
***
## Example usage:
```php
use GT\Ulid\Ulid;
$exampleDataSource->create(new Person(
new Ulid("pet"),
name: "Cody",
age: 5,
));
```
# Proudly sponsored by
[JetBrains Open Source sponsorship program](https://www.jetbrains.com/community/opensource/)
[](https://www.jetbrains.com/community/opensource/)