germania-kg / uuidserviceprovider
1.2.2
2022-05-30 13:38 UTC
Requires
- pimple/pimple: ^3.0
- ramsey/uuid: ^3.7|^4.0
Requires (Dev)
- php-coveralls/php-coveralls: ^2.0
- phpspec/prophecy-phpunit: ^2.0
- phpunit/phpunit: ^9.0
This package is auto-updated.
Last update: 2024-09-16 17:37:00 UTC
README
Pimple 服务提供者,用于与 Ben Ramsey 的 ramsey/uuid 包一起使用
使用 Composer 安装
$ composer require germania-kg/uuidserviceprovider
设置
<?php use Germania\UuidServiceProvider\UuidServiceProvider; // A. Use with Slim or Pimple $app = new \Slim\App; $dic = $app->getContainer(); $dic = new Pimple\Container; // B. Register Service Provider. $dic->register( new UuidServiceProvider );
服务
UUID.new
工厂:返回一个新的版本 4(随机)UUID 对象,作为 Ramsey\Uuid\Uuid 实例。
<?php $uuid4 = $dic['UUID.new'];
UUID.new.hex
返回 UUID.new 对象的十六进制字符串表示。
<?php $uuid4_hex = $dic['UUID.new.hex'];
UUID.Factory
返回一个可调用的函数,该函数返回 UUID 对象作为 Ramsey\Uuid\Uuid 实例。
<?php $factory = $dic['UUID.Factory']; $uuid4 = $factory();
UUID.HexFactory
返回一个可调用的函数,该函数返回 UUID.new 对象的十六进制字符串表示。
<?php $factory = $dic['UUID.HexFactory']; $uuid4_hex = $factory();
开发
$ git clone https://github.com/GermaniaKG/UuidServiceProvider.git
$ cd UuidServiceProvider
$ composer install
单元测试
要么将 phpunit.xml.dist
复制到 phpunit.xml
并根据您的需求进行适配,要么保持原样。运行 PhpUnit 测试或 composer 脚本,如下所示
$ composer test # or $ vendor/bin/phpunit