nurfachmi/cuid2

A PHP library for generating collision-resistant ids (CUIDs).

0.1.2 2024-01-31 08:51 UTC

This package is auto-updated.

Last update: 2024-08-30 01:55:29 UTC


README

GitHub Workflow Status (with event)

PHP Version Packagist Downloads GitHub

A PHP implementation of collision-resistant ids (prior). You can read more about CUIDs from the official project website.

Getting Started

You can install nurfachmi/cuid2 as a composer package:

composer require nurfachmi/cuid2

Quick Example

<?php
require_once 'vendor/autoload.php';

// new (default length of 24)
$cuid = new Nurfachmi\Cuid2\Cuid2();

// implicit casting
echo $cuid; // hw8kkckkgwkk0oo0gkw0o8sg

// explicit casting
echo $cuid->toString(); // hw8kkckkgwkk0oo0gkw0o8sg

// new (with custom length)
$cuid = new Nurfachmi\Cuid2\Cuid2(10);
echo $cuid; // psk8844ck4

Testing

composer test

License

The MIT License (MIT). Please see License File for more information.