Laravel How to fix Call to undefined function uuid_create()

If you are running a Laravel application and getting a “Call to undefined function uuid_create()” error, you need to install the following package via composer: symfony/polyfill-uuid

composer require symfony/polyfill-uuid

Universally unique identifiers (UUIDs) are 128-bit numbers used to identify information in computer systems. Their use is becoming increasingly popular in PHP/Symfony applications, where some developers prefer them over traditional auto-incrementing integer IDs for database records.

$uuid = uuid_create(UUID_TYPE_RANDOM);
$isValid = uuid_is_valid($uuid);//true/false

Although there are different variants and versions of UUIDs, most developers rely on external libraries such as the UUID PECL package and the ramsey/uuid library to generate these UUIDs. To make it easier to use the PHP 7.3 JsonException class and the PHP 7.4 password_algos() function in any PHP version, Symfony Polyfills provide reimplementations of popular functions, classes and constants.

You can also generate UUID codes online here:

In response to the growing popularity of UUIDs, a new UUID Polyfill has been created. This polyfill allows developers to use the features of the UUID PECL package in PHP 5.3 and higher. After installing the polyfill, developers can create UUIDs and check their validity with functions such as uuid_create(), uuid_is_valid(), uuid_compare(), uuid_is_null(), uuid_type(), uuid_variant(), uuid_time(), uuid_mac(), uuid_parse() and uuid_unparse().

However, the UUID Polyfill should not be used as a replacement for full-featured libraries such as ramsey/uuid. When it comes to performance, the polyfill is either faster or slower than the PECL package depending on the UUID version being created.

Related posts:

  1. Laravel – remove vendor folder from git
  2. How to Install Composer on MacOS Ventura: 3 Different Ways
  3. How Does Laravel Rate Limiting Work?