Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Nano Id Laravel Package

snortlin/nano-id

Laravel-friendly NanoID generator for PHP: create short, URL-safe, collision-resistant IDs with configurable length and alphabet. Simple API, lightweight and fast—ideal for public identifiers, tokens, and model keys without exposing sequential IDs.

View on GitHub
Deep Wiki
Context7

Nano ID

A tiny, secure, URL-friendly, unique string ID generator for PHP.

This package is PHP implementation of ai's nanoid. Read its documentation for more information.

  • Fast. It is faster than UUID.
  • Safe. It uses cryptographically strong random APIs. Can be used in clusters.
  • Compact. It uses a larger alphabet than UUID (A-Za-z0-9_-). So ID size was reduced from 36 to 21 symbols.
  • Customizable. Size, alphabet and Random Bytes Generator may be overridden.

Installation

The preferred method of installation is via Composer:

composer require snortlin/nano-id

Usage

Base usage

use Snortlin\NanoId\NanoId;

$nanoId = NanoId::nanoId(); // "unQ87dO06B5B-Ybq2Aum5"

// Custom size, default = 21
$nanoId = NanoId::nanoId(16); // "6PUg-8nn5IQrvKNw"

// Custom size and alphabet
$nanoId = NanoId::nanoId(16, '0123456789abcdef'); // "58b141975c2b72f3"

Custom alphabet

use Snortlin\NanoId\NanoId;

// Default size (21), numbers (0123456789)
$nanoId = NanoId::nanoId(NanoId::SIZE_DEFAULT, NanoId::ALPHABET_NUMBERS); // "782295634533276321176"

// Custom size, numbers and English alphabet without unreadable letters: 1, l, I, 0, O, o, u, v, 5, S, s, 2, Z
$nanoId = NanoId::nanoId(12, NanoId::ALPHABET_ALPHA_NUMERIC_READABLE); // "AcFQM9X3pCi8"

Faster and Non-Secure

By default, Nano ID uses random bytes generation for security and low collision probability. If you are not so concerned with security and more concerned with performance, you can use the faster non-secure generator.

use Snortlin\NanoId\NanoId;

$nanoId = NanoId::nanoIdNonSecure();

// Custom size, default = 21
$nanoId = NanoId::nanoIdNonSecure(16);

// Custom size and alphabet
$nanoId = NanoId::nanoIdNonSecure(16, '0123456789abcdef');

Tools

Credits

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
ilhamsyabani/laravel-volt-starter
thethunderturner/filament-latex
ghostcompiler/laravel-querybuilder
webrek/laravel-telescope-mongodb
anousss007/blatui
zatona-eg/zatona-eg-api
cocosmos/filament-sticky-save-bar
patrickbussmann/oauth2-apple
3brs/enterprise-security-bundle
anousss007/vigilance
supportpal/eloquent-model
ardenexal/fhir-models
laravel-at/laravel-image-sanitize
romalytar/yammi-audit-log-laravel
ardenexal/fhir-validation
arshaviras/weather-widget
laravel-chronicle/core
sunchayn/nimbus
daikazu/eloquent-salesforce-objects
unseen-codes/chat