How to Generate a UUID in PHP 7
Here is a little snippet for generating a UUID in PHP 7
$data = random_bytes(16);
$data = chr(ord($data) & 0x0f | 0x40);
$data = chr(ord($data) & 0x3f | 0x80);
return vsprintf('%s%s-%s-%s-%s-%s%s%s', str_...
How to Enable UUIDs in Postgres
The first thing you'll need to do is enable the extension
create extension "uuid-ossp";
To test that it's working
For more info on which version of the algorithm you should use refer to the documentation.