Non UUID based identity objects for PHP
This package extends phpgears/identity to provide non UUID-based identities
composer require phpgears/identity-extra
Require composer autoload file
require './vendor/autoload.php';
You need to install and enable ext-mongodb through your distro's repos or PECL
sudo pecl install mongodb
use Gears\Identity\Extra\ObjectIdIdentity;
use Gears\Identity\Extra\ObjectIdIdentityGenerator;
use MongoDB\BSON\ObjectId;
$identity = ObjectIdIdentity::fromString((string) new ObjectId());
// From generator
$identity = (new ObjectIdIdentityGenerator())->generate();
you need to require https://github.com/robinvdvleuten/php-ulid
composer require obinvdvleuten/ulid
use Gears\Identity\Extra\UlidIdentity;
use Gears\Identity\Extra\UlidIdentityGenerator;
use Ulid\Ulid;
$identity = UlidIdentity::fromString((string) Ulid::generate());
// From generator
$identity = (new UlidIdentityGenerator())->generate();
Find more information about ULID at https://github.com/ulid/spec
you need to require https://github.com/tuupola/ksuid
composer require tuupola/ksuid
use Gears\Identity\Extra\KsuidIdentity;
use Gears\Identity\Extra\KsuidIdentityGenerator;
use Tuupola\KsuidFactory;
$identity = KsuidIdentity::fromString((string) KsuidFactory::create());
// From generator
$identity = (new KsuidIdentityGenerator())->generate();
Find more information about KSUID at https://github.com/segmentio/ksuid
you need to require https://github.com/fpay/xid-php
composer require fpay/xid-php
use Gears\Identity\Extra\XidIdentity;
use Gears\Identity\Extra\XidIdentityGenerator;
use Fpay\Xid\Generator;
$identity = XidIdentity::fromString((string) Generator::create());
// From generator
$identity = (new XidIdentityGenerator())->generate();
Find more information about Xid at https://github.com/fpay/xid-php
Found a bug or have a feature request? Please open a new issue. Have a look at existing issues before.
See file CONTRIBUTING.md
See file LICENSE included with the source code for a copy of the license terms.