Download the PHP package malico/laravel-nanoid without Composer
On this page you can find all versions of the php package malico/laravel-nanoid. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package laravel-nanoid
Laravel Nanoid
Generate Nanoid-based, Stripe-style IDs for your Eloquent models.
Installation
Quick Start
Add HasNanoids to your model:
Use a string primary key in your migration:
You can also scaffold migrations with:
make:nanoid-migration accepts the same arguments as make:migration.
Configuration
You can configure generated IDs per model with these properties (or methods with the same names):
nanoidPrefix: static prefix, for exampleord_nanoidLength: fixed length (10) or random range ([10, 20])nanoidAlphabet: allowed charactersnanoidFormat: structured format like{3}-{4}
Each option supports either:
- A single value for all unique ID columns
- A keyed array per column
nanoidPrefix
nanoidLength
nanoidAlphabet
nanoidFormat
Full model example
Format Patterns
Use nanoidFormat when you want readable, segmented IDs.
Supported placeholders:
{n}generates exactlynrandom characters{min-max}generates a random length betweenminandmax
All other characters are kept as-is (-, _, ., spaces, and so on).
Rules:
- If
nanoidFormatis set, it fully controls the generated shape nanoidFormatcannot be combined withnanoidPrefixnanoidFormatcannot be combined withnanoidLength- Without
nanoidFormat, generation falls back tonanoidPrefix + nanoidLength - With per-column arrays, these conflict rules apply per column
Benchmark
Run the included micro-benchmark:
Choosing an ID Type
- Use this package when you want random, non-sequential, human-friendly IDs (for example
p-8F4Z2K9T7Q1M) - Use Laravel
HasUlidswhen you want sortable IDs that preserve creation order better - Use auto-incrementing integers when you need simple sequential IDs and the best insert locality
If your system requires strictly incremental IDs, this package is not the right tool.
Safety Notes
- Short IDs are easier to collide and easier to guess; increase length for public or sensitive resources
- NanoID's own guidance compares default NanoID entropy with UUID v4 (similar collision profile)
- Always choose size/alphabet based on your scale and threat model
- For custom sizes, check collision estimates with: https://zelark.github.io/nano-id-cc/
If you are upgrading from 0.x, see UPGRADE.MD.
Author
Ndifon Desmond Yong
All versions of laravel-nanoid with dependencies
illuminate/auth Version ^10.0|^11.0|^12.0|^13.0
illuminate/support Version ^10.0|^11.0|^12.0|^13.0