setono/client

用于识别浏览器客户端的PHP抽象层

维护者

详细信息

github.com/Setono/client

源代码

问题

资助包维护!
Setono

v1.1.1 2024-05-07 09:41 UTC

This package is auto-updated.

Last update: 2024-09-07 10:19:30 UTC


README

Latest Version Software License Build Status Code Coverage Mutation testing

安装

composer require setono/client

如果您不使用自己的客户端ID生成策略,您还应安装symfony/uidramsey/uuid

# If you want to use symfony/uid
composer require symfony/uid

# If you want to use ramsey/uuid
composer require ramsey/uuid

使用方法

use Setono\Client\Client;

// initialization with a generated id and an empty metadata object
$client = new Client();

// initialization with your own id and existing metadata
$client = new Client('my-client-id', ['foo' => 'bar']);

// get the client id
$id = $client->id;

// set metadata
$client->metadata->set('foo', 'bar');

// set metadata that expires in 1 hour
$client->metadata->set('foo', 'bar', 3600);

// get metadata
$client->metadata->get('foo');

// remove metadata
$client->metadata->remove('foo');

还有一个Cookie类,可以用来在cookie中存储客户端ID。