https://github.com/projectsaturnstudios/quickuuid
Simple helper functions to easily generate UUIDs (v4 and v5).
https://github.com/projectsaturnstudios/quickuuid
Last synced: 6 months ago
JSON representation
Simple helper functions to easily generate UUIDs (v4 and v5).
- Host: GitHub
- URL: https://github.com/projectsaturnstudios/quickuuid
- Owner: projectsaturnstudios
- License: mit
- Created: 2025-07-02T12:33:54.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-07-02T12:36:19.000Z (about 1 year ago)
- Last Synced: 2025-09-09T13:05:44.926Z (10 months ago)
- Language: PHP
- Size: 4.88 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.md
Awesome Lists containing this project
README
# ProjectSaturnStudios/QuickUUID
A simple PHP library providing helper functions to easily generate version 4 (random) and version 5 (name-based, SHA-1) UUIDs. It leverages the robust `ramsey/uuid` package under the hood.
## Features
- Generate UUIDv4.
- Generate UUIDv5 with a specified name and an optional namespace.
- A primary helper `new_uuid()` that intelligently calls either v4 or v5 generation based on provided arguments.
- Configurable default namespace for UUIDv5 generation.
## Installation
Install the package via Composer:
```bash
composer require projectsaturnstudios/quickuuid
```
## Basic Usage
```php
```
### UUIDv5 Namespace Configuration
The `new_uuid5()` and `new_uuid()` (when generating a v5 UUID) functions use a default namespace. This default is `Ramsey\Uuid\Uuid::NAMESPACE_DNS`.
You can change this application-wide default by defining the `QUICKUUID_DEFAULT_V5_NAMESPACE` constant *before* the `quickuuid/src/Helpers/helpers.php` file is loaded by Composer. Make sure the value you define is a valid UUID string.
Example (e.g., in your `bootstrap/app.php` or an early Composer autoloaded file):
```php
if (!defined('QUICKUUID_DEFAULT_V5_NAMESPACE')) {
define('QUICKUUID_DEFAULT_V5_NAMESPACE', 'YOUR-OWN-DEFAULT-NAMESPACE-UUID'); // Replace with your actual UUID
}
// Composer will then load quickuuid's helpers, which will use this constant.
```
## Dependencies
- PHP ^8.2
- `ramsey/uuid`: ^4.7
## Running Quality Assurance
This package uses PHPUnit for tests and PHPStan for static analysis.
To run tests:
```bash
composer test
```
To run static analysis:
```bash
composer analyse
```
## License
This package is licensed under the MIT License. See the [LICENSE.md](LICENSE.md) file for details.
## Contributing
Contributions are welcome! Please feel free to submit a pull request or open an issue.