phpgears / identity-extra
PHP 的身份对象
0.2.2
2020-11-20 12:09 UTC
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-09-20 22:48:25 UTC
README
Identity Extra
基于非 UUID 的 PHP 身份对象
此包扩展了 phpgears/identity 以提供非 UUID 基础的身份对象
安装
Composer
composer require phpgears/identity-extra
使用
需要 require composer 自动加载文件
require './vendor/autoload.php';
Mongo ObjectId
您需要通过您的发行版仓库或 PECL 安装并启用 ext-mongodb
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(全球唯一字母顺序排序标识符)
您需要 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();
有关 ULID 的更多信息,请访问 https://github.com/ulid/spec
KSUID(K-可排序全球唯一 ID)
您需要 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();
有关 KSUID 的更多信息,请访问 https://github.com/segmentio/ksuid
Xid(全球唯一 ID)
您需要 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();
有关 Xid 的更多信息,请访问 https://github.com/fpay/xid-php
贡献
发现了一个错误或有功能请求? 请打开一个新问题。在提交之前查看现有的问题。
查看文件 CONTRIBUTING.md
许可证
请参阅源代码中包含的文件 LICENSE 以获取许可证条款副本。