Skip to content

Best way to generate a UUID in the laravel framework #54523

Discussion options

You must be logged in to vote

You can use this.
It uses random bytes and puts them in the right positions by using the vsprintf function.

Random bytes

$UUID = vsprintf( '%s%s-%s-%s-%s-%s%s%s', str_split(bin2hex(random_bytes(16)), 4) );

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@shaedrich
Comment options

Answer selected by nielsprinsfps
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants