Announcing GUID v3.0 - Modern, lightweight GUID generation for PHP
A Modern, lightweight GUID generation for PHP 8.2+
The first release of this package focused on one clear goal: generate GUIDs with minimal fuss.
Version 3.0 keeps that same spirit and modernizes the package for today’s PHP ecosystem.
What’s new in v3.0
- PHP 8.2+ baseline with strict typing
- Zero runtime dependencies
- Tiny, stable public API
- Optional extensibility via GeneratorInterface
- Production-quality gates: tests, static analysis, linting, and CI
Why this release matters
v3.0 is built for projects that want reliability without bloat.
It stays small, readable, and fast, while improving maintainability and long-term confidence.
- No framework lock-in
- No container setup
- No runtime dependency overhead
- Predictable GUID output behavior
Install
composer require sudiptpa/guid
Class API
<?php
declare(strict_types=1);
use Sujip\Guid\Guid;
$guid = new Guid();
echo $guid->create();
// example: 2b23924f-0eaa-4133-848e-7ce1edeca8c9
echo $guid->create(false);
// example: {2b23924f-0eaa-4133-848e-7ce1edeca8c9}
Helper API
<?php
declare(strict_types=1);
echo guid();
// example: 2b23924f-0eaa-4133-848e-7ce1edeca8c9
echo guid(false);
// example: {2b23924f-0eaa-4133-848e-7ce1edeca8c9}
Optional extensibility (still minimal)
Default usage is unchanged. If you need custom behavior, implement GeneratorInterface:
<?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
Compatibility notes
- v3.0 requires PHP 8.2+
- Standalone public behavior remains stable for valid inputs
- Need legacy PHP (<8.2)? Stay on
sudiptpa/guid:^2.0
Thank you for using and supporting this package.
v3.0 is a modernization release that keeps the original taste intact: simple, lightweight, and dependable GUID generation for PHP.
Also Read: v2.0 - Create unique GUID with PHP