| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
A high-performance PHP extension for working with 128-bit identifiers including UUIDs and ULIDs.
If you use devenv, the repository includes a ready-to-use environment with PHP, PHP development headers (php-config), Composer, Zig, and ZLS:
devenv shellInside the devenv shell, you can use the provided helper scripts:
build # zig build
test # zig build + PHPUnit
dev # zig build dev
bench # zig build + composer install + composer benchgit clone https://github.com/your-org/php-ext-identifier.git
cd php-ext-identifier
zig build dev # Build + test in one commandFor production installation:
zig build install-system # Install to system PHP (requires sudo)Add to your php.ini:
extension=identifieruse Identifier\Uuid\Version4;
use Identifier\Uuid\Version7;
use Identifier\Ulid;
// Generate random UUID v4
$uuid = Version4::generate();
echo $uuid->toString(); // e.g., "550e8400-e29b-41d4-a716-446655440000"
// Generate timestamp-based UUID v7
$uuid7 = Version7::generate();
echo $uuid7->toString();
// Generate ULID
$ulid = Ulid::generate();
echo $ulid->toString(); // e.g., "01ARZ3NDEKTSV4RRFFQ69G5FAV"use Identifier\State\Fixed;
use Identifier\Uuid\Version4;
// Create deterministic state for testing
$ctx = Fixed::create(1640995200000, 12345);
// Generate deterministic UUIDs
$uuid1 = Version4::generate($ctx);
$uuid7 = Version7::generate($ctx);
$ulid = Ulid::generate($ctx);
// Both calls with same state will produce same resultsThis extension is fully thread-safe for ULID monotonic generation in multi-threaded PHP environments (ZTS builds). The implementation uses PHP's TSRM (Thread Safe Resource Manager) to ensure proper thread isolation.
The same extension binary works for both ZTS (thread-safe) and non-ZTS PHP builds:
# Check if your PHP build supports threading
php -m | grep -i zts
php-config --configure-options | grep -i ztsFor web servers that use threading (like Apache mod_worker or IIS), ensure you're using a ZTS PHP build to get full thread safety benefits.
Check the stub file for a detailed API documentation.
Tests are written with PHPUnit under test/Test and are run against the locally built extension.
zig build test # Build the extension and run PHPUnit
zig build dev # Build + test
composer test # Run PHPUnit after the extension has been builtWith devenv:
devenv shell test # Build and run PHPUnit inside the managed environment
devenv test # Validate the environment and run the test suiteBenchmarks use PHPBench and compare this extension against symfony/uid and ramsey/uuid.
zig build
composer install
composer benchWith devenv:
devenv shell benchThis project is licensed under the MIT License - see the LICENSE file for details.
| Back | FazBrowse Home | New Git URL |