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: about 2 months 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 (over 8 years ago)
- Default Branch: master
- Last Pushed: 2023-01-27T05:43:42.000Z (over 2 years ago)
- Last Synced: 2025-04-07T21:11:45.321Z (3 months ago)
- Topics: generator, hacktoberfest, identifier, php, ulid
- Language: PHP
- Homepage: https://packagist.org/packages/robinvdvleuten/ulid
- Size: 35.2 KB
- Stars: 450
- Watchers: 7
- Forks: 32
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Universally Unique Lexicographically Sortable Identifier
[](https://packagist.org/packages/robinvdvleuten/ulid)
[](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.