phpgears / identity-extra
Identity object for PHP
Requires
- php: ^7.1
- phpgears/identity: ~0.2.4
Requires (Dev)
- ext-mongodb: *
- brainmaestro/composer-git-hooks: ^2.8
- fpay/xid-php: ^1.0
- friendsofphp/php-cs-fixer: ^2.16
- hashids/hashids: ^3.0|^4.0
- infection/infection: ^0.13|^0.15|^0.18|^0.19
- overtrue/phplint: ^1.2
- pascaldevink/shortuuid: ^2.1
- pedrotroller/php-cs-custom-fixer: ^2.19
- phpmd/phpmd: ^2.8
- phpstan/extension-installer: ^1.0.3
- phpstan/phpstan: ^0.12
- phpstan/phpstan-deprecation-rules: ^0.12
- phpstan/phpstan-strict-rules: ^0.12
- phpunit/phpunit: ^7.5|^8.0
- povils/phpmnd: ^2.1
- roave/security-advisories: dev-master
- robinvdvleuten/ulid: ^3.0|^4.0
- sebastian/phpcpd: ^4.0
- squizlabs/php_codesniffer: ^3.5
- thecodingmachine/phpstan-strict-rules: ^0.12
- tuupola/ksuid: ^2.0
Suggests
- ext-mongodb: For ObjectId identities
- fpay/xid-php: For Globally Unique ID identities
- robinvdvleuten/ulid: For Universally Unique Lexicographically Sortable ID identities
- tuupola/ksuid: For K-Sortable Globally Unique identities
This package is auto-updated.
Last update: 2024-11-20 23:14:07 UTC
README
Identity Extra
Non UUID based identity objects for PHP
This package extends phpgears/identity to provide non UUID-based identities
Installation
Composer
composer require phpgears/identity-extra
Usage
Require composer autoload file
require './vendor/autoload.php';
Mongo ObjectId
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();
ULID (Universally Unique Lexicographically Sortable Identifier)
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
KSUID (K-Sortable Globally Unique IDs)
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
Xid (Globally Unique ID)
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
Contributing
Found a bug or have a feature request? Please open a new issue. Have a look at existing issues before.
See file CONTRIBUTING.md
License
See file LICENSE included with the source code for a copy of the license terms.