Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tuupola/ulid
Universally Unique Lexicographically Sortable Identifier
https://github.com/tuupola/ulid
Last synced: 2 months ago
JSON representation
Universally Unique Lexicographically Sortable Identifier
- Host: GitHub
- URL: https://github.com/tuupola/ulid
- Owner: tuupola
- License: mit
- Created: 2018-04-15T16:42:35.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2021-10-21T10:09:49.000Z (about 3 years ago)
- Last Synced: 2024-09-07T22:56:49.338Z (4 months ago)
- Language: PHP
- Size: 19.5 KB
- Stars: 3
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# [WIP] PHP ULID
This library implements the [Universally Unique Lexicographically Sortable Identifier](https://github.com/alizain/ulid) from Alizain Feerasta.
[![Latest Version](https://img.shields.io/packagist/v/tuupola/ulid.svg?style=flat-square)](https://packagist.org/packages/tuupola/ulid)
[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE)
[![Build Status](https://img.shields.io/github/workflow/status/tuupola/ulid/Tests/master?style=flat-square)](https://github.com/tuupola/ulid/actions)
[![Coverage](https://img.shields.io/codecov/c/github/tuupola/ulid.svg?style=flat-square)](https://codecov.io/github/tuupola/ulid)## Install
Install with [composer](https://getcomposer.org/).
``` bash
$ composer require tuupola/ulid
```## Usage
``` php
use Tuupola\Ulid;$ulid = new Ulid;
print $ulid; /* 0001DD70YKYBES1P98DHWKTWZW */
//$ulid = ulid::fromString("0o5Fs0EELR0fUjHjbCnEtdUwQe3");
print $ulid->timestamp(); /* 1523811283 */
print bin2hex($ulid->payload()); /* f2dd90d9286c793d73fc */$datetime = (new \DateTimeImmutable)
->setTimestamp($ulid->unixtime())
->setTimeZone(new \DateTimeZone("UTC"));print $datetime->format("Y-m-d H:i:s"); /* 2018-04-15 16:54:43 */
```## Testing
You can run tests either manually or automatically on every code change. Automatic tests require [entr](http://entrproject.org/) to work.
``` bash
$ composer test
`````` bash
$ brew install entr
$ composer watch
```## Contributing
Please see [CONTRIBUTING](CONTRIBUTING.md) for details.
## Security
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
## License
The MIT License (MIT). Please see [License File](LICENSE) for more information.