An open API service indexing awesome lists of open source software.

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.

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.

***


Build status


Code quality


Code coverage


Current version


PHP.Gt/Ulid documentation

## 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/)

[![JetBrains logo.](https://resources.jetbrains.com/storage/products/company/brand/logos/jetbrains.svg)](https://www.jetbrains.com/community/opensource/)