Download the PHP package highperapp/uuid without Composer
On this page you can find all versions of the php package highperapp/uuid. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download highperapp/uuid
More information about highperapp/uuid
Files in highperapp/uuid
Package uuid
Short Description High-performance UUID generator library implementing RFC 9562 with optional Rust FFI acceleration
License MIT
Informations about the package uuid
UUID Library
A high-performance UUID generator library implementing RFC 9562 with support for UUIDv1-v8, featuring optional Rust FFI acceleration, async/sync compatibility, and high-concurrency collision prevention.
Features
- ✅ Complete RFC 9562 Support: UUIDv1, v3, v4, v5, v6, v7, v8
- ⚡ High Performance: Optional Rust FFI acceleration
- 🔄 Async/Sync Compatible: Works with both paradigms seamlessly
- 🚀 Concurrency Support: RevoltPHP, AmphpV3, Parallel integration
- 🛡️ Collision Prevention: Advanced mechanisms for high-throughput scenarios
- 🔧 Configurable: Multiple RNG providers and performance options
- 📦 Zero Dependencies: Pure PHP fallback when FFI unavailable
- ✅ PHP 8.3+ Compatible: Supports PHP 8.3 and later versions
Installation
Optional: Rust FFI Acceleration
For maximum performance, you can enable Rust FFI acceleration which can improve UUID generation speed by up to 10x.
Prerequisites
-
Install PHP FFI Extension (required for Rust acceleration):
-
Verify FFI Installation:
-
Install Rust (if not already installed):
- Verify Installation:
Build the Rust Library
The compiled library will be available at rust/target/release/libuuid_ffi.so
(Linux/macOS) or rust/target/release/uuid_ffi.dll
(Windows).
Troubleshooting FFI Issues
If you encounter FFI-related errors:
-
FFI Not Available:
-
FFI Preloading Issues:
-
Permission Issues:
- Library Path Issues:
Development vs Production
- Development: The library automatically falls back to pure PHP if Rust FFI is unavailable
- Production: For optimal performance, ensure both FFI extension and Rust library are available
- CI/CD: Add both FFI installation and Rust build steps to your deployment pipeline
- Docker: Include FFI in your PHP Docker image and build Rust during image creation
Quick Start
UUID Versions
UUIDv1 - Timestamp + MAC Address
UUIDv3 - MD5 Name-based
UUIDv4 - Random
UUIDv5 - SHA-1 Name-based
UUIDv6 - Reordered Timestamp
UUIDv7 - Unix Timestamp (Recommended)
UUIDv8 - Custom Format
Performance Configuration
High Performance Setup
Custom Configuration
Thread-Safe Operations
For concurrent environments (Swoole, ReactPHP, etc.), use the thread-safe factory:
Async/Concurrent Generation
Prerequisites for Async Features
Install optional async dependencies for enhanced capabilities:
Async Generation
High-Throughput Scenarios
Pipeline Processing
Async Configuration
Random Number Providers
Collision Prevention
The library includes advanced collision prevention mechanisms:
Benchmarking
Run performance tests to validate performance on your system:
Expected Performance Ranges
- Development environment: 300,000 - 600,000 UUIDs/second
- Production environment: 600,000 - 900,000 UUIDs/second
- With Rust FFI: 1,000,000+ UUIDs/second
- High-concurrency scenarios: 400,000 - 800,000 UUIDs/second
Performance depends on:
- CPU speed and architecture
- PHP version and configuration
- Available memory
- FFI extension availability
- Rust library compilation
Integration Examples
Laravel
Symfony
Swoole/OpenSwoole Integration
ReactPHP Integration
Database Storage
Performance Characteristics
Version | Performance | Use Case | Sortable | Collision Risk |
---|---|---|---|---|
v1 | High | Legacy systems | No | Very Low |
v3 | Medium | Name-based, reproducible | No | None |
v4 | High | General purpose | No | Negligible |
v5 | Medium | Name-based, reproducible | No | None |
v6 | High | Sortable timestamp | Yes | Very Low |
v7 | Highest | Recommended for new apps | Yes | Very Low |
v8 | Variable | Custom implementations | Variable | Variable |
Throughput Benchmarks
Benchmarks measured on PHP 8.3.6, Linux x86_64. Performance may vary based on hardware and configuration.
Configuration | UUIDs/second | Memory/UUID | Notes |
---|---|---|---|
Pure PHP v4 | ~600,000-900,000 | <100 bytes | Actual performance exceeds estimates |
Pure PHP v7 | ~700,000-900,000 | <100 bytes | Recommended for new applications |
Pure PHP v1 | ~600,000 | <100 bytes | Legacy timestamp-based |
Pure PHP v3/v5 | ~850,000-900,000 | <100 bytes | Name-based UUIDs (cached) |
Rust FFI v4 | ~1,000,000+ | <50 bytes | Requires FFI extension + Rust build |
Rust FFI v7 | ~1,200,000+ | <50 bytes | Optimal for high-throughput scenarios |
Concurrent v4 | ~400,000-800,000 | Variable | Depends on worker count and overhead |
Memory Usage Notes:
- Memory per UUID is minimal in normal usage due to PHP's garbage collection
- Bulk operations (10,000+ UUIDs) may use ~100-200 bytes per UUID temporarily
- String representation adds ~36 bytes per UUID when stored
- Memory usage scales linearly with batch size
Configuration Options
Error Handling
Development Setup
Prerequisites
-
PHP 8.3+ with extensions:
-
Composer (for PHP dependencies):
- Rust (optional, for FFI acceleration):
Development Workflow
Testing
Requirements
Core Requirements
- PHP 8.3 or higher
ext-openssl
(required for secure random generation)ext-json
(required for configuration)
Optional Dependencies
ext-ffi
(optional, for Rust FFI acceleration)revolt/event-loop
^1.0 (optional, for async operations)amphp/amp
^3.0 (optional, for async operations)amphp/parallel
^2.0 (optional, for concurrent processing)
Note: The library works perfectly without optional dependencies, providing graceful fallbacks.
FFI Configuration
For production environments, consider adding these settings to your php.ini
:
Contributing
- Fork the repository
- Create a feature branch
- Add tests for new functionality
- Ensure all tests pass
- Submit a pull request
License
MIT License. See LICENSE for details.