Download the PHP package castor/identifier without Composer
On this page you can find all versions of the php package castor/identifier. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download castor/identifier
More information about castor/identifier
Files in castor/identifier
Package identifier
Short Description High-performance 128-bit identifier extension for PHP (UUIDs and ULIDs)
License MIT
Informations about the package identifier
Extension Identifier
A high-performance PHP extension for working with 128-bit identifiers including UUIDs and ULIDs.
Features
- 128-bit Base Class:
Identifier\Bit128for all 128-bit identifiers - Complete UUID Support: All UUID versions (1, 3, 4, 5, 6, 7) with proper RFC compliance
- ULID Support: Universally Unique Lexicographically Sortable Identifiers with monotonic ordering
- Thread Safety: Full thread safety for ULID monotonic generation using TSRM (Thread Safe Resource Manager)
- State System: Deterministic generation for testing with
State\Fixed - Exceptional Performance: Native C implementation delivering 9.9M+ ULID ops/sec, 2.8M+ UUID ops/sec
- Type Safety: Proper PHP class hierarchy with inheritance
Installation
Requirements
- PHP 8.3 or higher
- Zig 0.15.2+ (Download from ziglang.org) - The amazing build system that makes this all possible
If you use devenv, the repository includes a ready-to-use environment with PHP, PHP development headers (php-config), Composer, Zig, and ZLS:
Inside the devenv shell, you can use the provided helper scripts:
Build and Install
For production installation:
Enable Extension
Add to your php.ini:
Quick Start
Testing with Fixed State
Thread Safety
This 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.
How Thread Safety Works
- Thread Isolation: Each thread maintains its own monotonic state (last timestamp and randomness)
- Zero Contention: No locks or synchronization required - each thread operates independently
- Monotonic Ordering: ULIDs generated within a single thread are guaranteed to be monotonically increasing
- Performance: Thread safety comes with zero performance overhead
Compatibility
- ✅ Apache mod_php (both threaded and non-threaded)
- ✅ Apache mod_worker (requires ZTS PHP build)
- ✅ Windows IIS (requires ZTS PHP build)
- ✅ PHP-FPM (process-based, inherently thread-safe)
- ✅ CLI (single-threaded by default)
Build Considerations
The same extension binary works for both ZTS (thread-safe) and non-ZTS PHP builds:
For 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.
API Documentation
Check the stub file for a detailed API documentation.
Testing
Tests are written with PHPUnit under test/Test and are run against the locally built extension.
With devenv:
Benchmarks
Benchmarks use PHPBench and compare this extension against symfony/uid and ramsey/uuid.
With devenv:
Contributing
- Fork the repository
- Create a feature branch
- Add tests for new functionality
- Ensure all tests pass (
zig build test) - Submit a pull request
License
This project is licensed under the MIT License - see the LICENSE file for details.
Acknowledgments
- Zig Programming Language - This project is built using Zig's incredible embedded C compiler and build system. Zig's seamless C interop, cross-compilation capabilities, and modern build tooling make it the perfect choice for PHP extension development. Special thanks to the Zig team for creating such an outstanding development experience.
- devenv - Provides a reproducible development environment for PHP extension work, including PHP development tooling, Composer, Zig, and ZLS.
- RFC 4122 - UUID specification
- RFC 9562 - Updated UUID specification
- ULID Specification - ULID format specification