Download the PHP package nice-yu/unique-code without Composer
On this page you can find all versions of the php package nice-yu/unique-code. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Table of contents
Download nice-yu/unique-code
More information about nice-yu/unique-code
Files in nice-yu/unique-code
Download nice-yu/unique-code
More information about nice-yu/unique-code
Files in nice-yu/unique-code
Vendor nice-yu
Package unique-code
Short Description Generate a unique invitation code within the current system
License MIT
Homepage https://github.com/nice-yu/unique-code
Package unique-code
Short Description Generate a unique invitation code within the current system
License MIT
Homepage https://github.com/nice-yu/unique-code
Keywords invitation codeunique code
Please rate this library. Is it a good library?
Informations about the package unique-code
Unique Code Library
English
Unit Tests
Default 6 Digits
- In general, 6 digits are sufficient for large-scale projects.
- If needed, you can modify it to 7 digits for cases like order calculations.
Digits | Maximum Value | Calculation |
---|---|---|
5 | 24,300,000 | 30^5 |
6 | 729,000,000 | 30^6 |
7 | 21,870,000,000 | 30^7 |
Installation
System Requirements
- PHP >= 7.4
Install Composer
If you haven't installed Composer yet, install it first:
Install Library
Parameter Description
Parameter Name | Default Value | Description |
---|---|---|
seed_number | MD5 | The seed number for shuffling the dictionary, default is to use system info hashed with MD5 |
dictionaries | 0-9, A-Z | Dictionary info, default removed characters 0, O, 1, I, and Y, Z as separators |
complement | Y-Z | Separator characters |
max | 6 | Number of digits to generate |
Default Parameters
- You can set parameters in a fluent manner
Get Parameters
Generate Unique Code
- Note the parameters set, if the maximum value is exceeded, it will return
null
- If used across multiple servers, ensure the
seed_number
value is consistent to avoid duplicate unique codes
Function Usage
- If you prefer not to use the class, you can use the functions directly, but mind the parameters
Error Handling
- If encoding fails (e.g., exceeding the maximum value), the
encode
method will returnnull
. Ensure to check for this when using. - In distributed systems, ensure all servers use the same
seed_number
to avoid encoding conflicts.
License
This project is licensed under the MIT License.
All versions of unique-code with dependencies
PHP Build Version
Package Version
Requires
php Version
>=7.4
The package nice-yu/unique-code contains the following files
Loading the files please wait ....