Download the PHP package unrulynatives/onym without Composer
On this page you can find all versions of the php package unrulynatives/onym. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download unrulynatives/onym
More information about unrulynatives/onym
Files in unrulynatives/onym
Package onym
Short Description Onym is a lightweight Laravel package designed to generate unique, structured, and meaningful filenames effortlessly.
License MIT
Homepage https://github.com/blaspsoft/onym
Informations about the package onym
Onym - Flexible Filename Generator
A flexible Laravel package for generating filenames using various strategies and options.
🚀 Features
- ✅ Flexible Filename Generation – Generate filenames dynamically using various strategies.
- 🎲 Multiple Strategies – Supports
random,uuid,timestamp,date,numbered,slug, andhash. - 🔧 Customizable Output – Specify filename, extension, and additional formatting options.
- 🎯 Laravel-Friendly – Designed to work seamlessly with Laravel's filesystem and configuration.
- 📂 Human-Readable & Unique Names – Ensures filenames are structured, collision-free, and easy to understand.
- ⚙️ Configurable Defaults – Define global settings in
config/onym.phpfor consistency across your application. - 🔌 Extensible & Developer-Friendly – Easily add custom filename strategies or modify existing ones.
Installation
You can install the package via composer:
You can publish the config file with:
Usage
Available Strategies
Random Strategy
Generates a random string of characters for the filename.
Options:
length(int): The length of the random string- Default: 16
- Example:
['length' => 8]generates "a1b2c3d4.txt"
prefix(string): String to prepend to the filename- Default: ''
- Example:
['prefix' => 'temp_']generates "temp_a1b2c3d4.txt"
suffix(string): String to append before the extension- Default: ''
- Example:
['suffix' => '_draft']generates "a1b2c3d4_draft.txt"
UUID Strategy
Generates a UUID v4 (universally unique identifier) for the filename.
Options:
prefix(string): String to prepend to the filename- Default: ''
- Example:
['prefix' => 'id_']generates "id_123e4567-e89b-12d3-a456-426614174000.txt"
suffix(string): String to append before the extension- Default: ''
- Example:
['suffix' => '_backup']generates "123e4567-e89b-12d3-a456-426614174000_backup.txt"
Timestamp Strategy
Adds a timestamp to the filename using PHP's DateTime formatting.
Options:
format(string): PHP DateTime format string- Default: 'Y-m-d_H-i-s'
- Common formats:
'Y-m-d_H-i-s'→ "2024-03-15_14-30-00"'YmdHis'→ "20240315143000"'U'→ Unix timestamp (e.g., "1710506400")
prefix(string): String to prepend to the filename- Default: ''
- Example:
['prefix' => 'log_']
suffix(string): String to append before the extension- Default: ''
- Example:
['suffix' => '_archive']
Date Strategy
Similar to timestamp but focused on date-only formats.
Options:
format(string): PHP DateTime format string- Default: 'Y-m-d'
- Common formats:
'Y-m-d'→ "2024-03-15"'Ymd'→ "20240315"'Y/m/d'→ "2024/03/15"
prefix(string): String to prepend to the filename- Default: ''
- Example:
['prefix' => 'dated_']
suffix(string): String to append before the extension- Default: ''
- Example:
['suffix' => '_version']
Numbered Strategy
Adds a number to the filename.
Options:
number(int): The number to append to the filename- Default: 1
- Example:
['number' => 5]
prefix(string): String to prepend to the filename- Default: ''
- Example:
['prefix' => 'rev_']
suffix(string): String to append before the extension- Default: ''
- Example:
['suffix' => '_final']
Slug Strategy
Converts the filename to a URL-friendly slug.
Options:
prefix(string): String to prepend to the filename- Default: ''
- Example:
['prefix' => 'post_']
suffix(string): String to append before the extension- Default: ''
- Example:
['suffix' => '_draft']
Hash Strategy
Generates a hash of the filename using various algorithms.
Options:
algorithm(string): The hashing algorithm to use- Default: 'md5'
- Available algorithms:
- 'md5' (32 characters)
- 'sha1' (40 characters)
- 'sha256' (64 characters)
- Any algorithm supported by PHP's
hash()function
prefix(string): String to prepend to the filename- Default: ''
- Example:
['prefix' => 'hash_']
suffix(string): String to append before the extension- Default: ''
- Example:
['suffix' => '_checksum']
Global Configuration
You can set default values for all strategies in your config/onym.php file:
These defaults can be overridden on a per-call basis using the options parameter in the make() and in all strategy methods.
License
Blasp is open-sourced software licensed under the MIT license.