Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/robinvdvleuten/php-ulid
A PHP port of alizain/ulid with some minor improvements.
https://github.com/robinvdvleuten/php-ulid
generator hacktoberfest identifier php ulid
Last synced: 4 days ago
JSON representation
A PHP port of alizain/ulid with some minor improvements.
- Host: GitHub
- URL: https://github.com/robinvdvleuten/php-ulid
- Owner: robinvdvleuten
- License: mit
- Created: 2017-02-10T12:41:40.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2023-01-27T05:43:42.000Z (almost 2 years ago)
- Last Synced: 2024-12-14T02:05:31.060Z (11 days ago)
- Topics: generator, hacktoberfest, identifier, php, ulid
- Language: PHP
- Homepage: https://packagist.org/packages/robinvdvleuten/ulid
- Size: 35.2 KB
- Stars: 445
- Watchers: 7
- Forks: 34
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Universally Unique Lexicographically Sortable Identifier
[![Latest Stable Version](https://poser.pugx.org/robinvdvleuten/ulid/v/stable)](https://packagist.org/packages/robinvdvleuten/ulid)
[![Build Status](https://img.shields.io/github/workflow/status/robinvdvleuten/php-ulid/run-tests.svg?style=flat-square)](https://github.com/robinvdvleuten/php-ulid/actions?query=workflow%3Arun-tests)A PHP port of [ulid/javascript](https://github.com/ulid/javascript) with some minor improvements.
## Installation
You can install the package via [Composer](https://getcomposer.org).
```bash
composer require robinvdvleuten/ulid
```## Usage
```php
use Ulid\Ulid;$ulid = Ulid::generate();
echo (string) $ulid; // 01B8KYR6G8BC61CE8R6K2T16HY// Or if you prefer a lowercased output
$ulid = Ulid::generate(true);
echo (string) $ulid; // 01b8kyr6g8bc61ce8r6k2t16hy// If you need the timestamp from an ULID instance
$ulid = Ulid::generate();
echo $ulid->toTimestamp(); // 1561622862// You can also generate a ULID for a specific UNIX-time in milliseconds
$ulid = Ulid::fromTimestamp(1593048767015);
// or with a lower cased output: $ulid = Ulid::fromTimestamp(1593048767015, true);
echo (string) $ulid; // 01EBMHP6H7TT1Q4B7CA018K5MQ
```### Testing
``` bash
composer test
```## Changelog
Please see [the GitHub "Releases" page](https://github.com/robinvdvleuten/php-ulid/releases) for more information on what has changed recently.
## Credits
As it's just a simple port of JavaScript to PHP code. All credits should go to the original [ULID](https://github.com/ulid/spec) specs.
- [Robin van der Vleuten](https://github.com/robinvdvleuten)
- [All Contributors](../../contributors)## License
The MIT License (MIT). Please see [License File](LICENSE) for more information.