Where can I find a php lib for generating time-bas

2019-06-09 16:07发布

问题:

Where can I find a php lib for generating time-based (v1) UUID?

Thanks in advance!

回答1:

I assume you want something like this:

  • http://www.shapeshifter.se/2008/09/29/uuid-generator-for-php/
  • https://github.com/fredriklindberg/class.uuid.php

E.g.:

require_once('class.uuid.php');
$str = UUID::generate(UUID::UUID_TIME, UUID::FMT_STRING, "abcdef");
echo $str;
// Output: 1b55e723-578b-4e34-d5cf-616263646566


回答2:

For a native RFC compliant implementation, see http://jkingweb.ca/code/php/lib.uuid/

This implementation does not include code for acquiring MAC address to generated real v1 UUIDs (neither does any native PHP implementation I've seen).

If you can use PECL uuid package, go for it.



标签: php uuid