sudiptpa / guid
A minimal GUID generator package for PHP.
Installs: 133 318
Dependents: 1
Suggesters: 0
Security: 0
Stars: 14
Watchers: 3
Forks: 7
Open Issues: 0
pkg:composer/sudiptpa/guid
Requires
- php: ^8.2
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.75
- phpstan/phpstan: ^1.12
- phpunit/phpunit: ^11.5
This package is auto-updated.
Last update: 2026-02-22 06:25:24 UTC
README
A minimal, dependency-free GUID generator for PHP with a tiny runtime footprint.
Requirements
- PHP 8.2+
Compatibility
- Supported and CI-tested on PHP 8.2, 8.3, 8.4, and 8.5.
- Need legacy PHP support below 8.2? Use
sudiptpa/guid:^2.0.
Installation
composer require sudiptpa/guid
Usage
Basic usage
<?php declare(strict_types=1); use Sujip\Guid\Guid; $guid = new Guid(); echo $guid->create(); // Example: 2b23924f-0eaa-4133-848e-7ce1edeca8c9
Global helper
<?php declare(strict_types=1); echo guid(); // Example: 2b23924f-0eaa-4133-848e-7ce1edeca8c9 echo guid(false); // Example: {2b23924f-0eaa-4133-848e-7ce1edeca8c9}
Extending generation behavior
Default usage is unchanged. If needed, provide your own generator:
<?php declare(strict_types=1); use Sujip\Guid\GeneratorInterface; use Sujip\Guid\Guid; final class CustomGenerator implements GeneratorInterface { public function generate(bool $trim = true): string { return $trim ? 'custom-guid' : '{custom-guid}'; } } $guid = new Guid(new CustomGenerator()); echo $guid->create(); // custom-guid
Public API stability
The package preserves the existing public behavior:
Sujip\Guid\Guid::create(bool $trim = true): stringguid(bool $trim = true): string
No runtime dependencies are required, and default usage stays a single class or helper call.
Development
composer install
composer lint
composer stan
composer test
Changelog
See CHANGELOG.md.
Contributing
See CONTRIBUTING.md.
Maintainer notes
See MAINTAINERS.md.
License
MIT. See LICENSE.