1. Go to this page and download the library: Download unrulynatives/onym library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
unrulynatives / onym example snippets
use Blaspsoft\Onym\Facades\Onym;
// Generate an 8-character random filename with prefix and suffix
Onym::make(strategy: 'random', options: [
'length' => 8,
'prefix' => 'temp_',
'suffix' => '_draft'
]);
// Result: "temp_a1b2c3d4_draft.txt"
// You can also use the random method directly
Onym::random(string $extension, ?array $options = [])
use Blaspsoft\Onym\Facades\Onym;
// Generate a UUID filename with prefix and suffix
Onym::make(strategy: 'uuid', options: [
'prefix' => 'id_',
'suffix' => '_backup'
]);
// Result: "id_123e4567-e89b-12d3-a456-426614174000_backup.txt"
// You can also use the uuid method directly
Onym::uuid(string $extension, ?array $options = [])
use Blaspsoft\Onym\Facades\Onym;
// Using timestamp with prefix and suffix
Onym::make('document', 'pdf', 'timestamp', [
'format' => 'Y-m-d_H-i-s',
'prefix' => 'log_',
'suffix' => '_archive'
]);
// Result: "log_2024-03-15_14-30-00_document_archive.pdf"
// You can also use the timestamp method directly
Onym::timestamp(string $defaultFilename, string $extension, ?array $options = [])
use Blaspsoft\Onym\Facades\Onym;
// Using date with prefix and suffix
Onym::make('document', 'pdf', 'date', [
'format' => 'Y-m-d',
'prefix' => 'dated_',
'suffix' => '_version'
]);
// Result: "dated_2024-03-15_document_version.pdf"
// You can also use the date method directly
Onym::date(string $defaultFilename, string $extension, ?array $options = [])
use Blaspsoft\Onym\Facades\Onym;
// Adding numbers with prefix and suffix
Onym::make('document', 'pdf', 'numbered', [
'number' => 5,
'prefix' => 'rev_',
'suffix' => '_final'
]);
// Result: "rev_document_5_final.pdf"
// You can also use the numbered method directly
Onym::numbered(string $defaultFilename, string $extension, ?array $options = [])
use Blaspsoft\Onym\Facades\Onym;
// Converting strings to slugs with prefix and suffix
Onym::make('My Document Name', 'pdf', 'slug', [
'prefix' => 'post_',
'suffix' => '_draft'
]);
// Result: "post_my-document-name_draft.pdf"
// You can also use the slug method directly
Onym::slug(string $defaultFilename, string $extension, ?array $options = [])
use Blaspsoft\Onym\Facades\Onym;
// Using hash with prefix and suffix
Onym::make('document', 'pdf', 'hash', [
'algorithm' => 'md5',
'prefix' => 'hash_',
'suffix' => '_checksum'
]);
// Result: "hash_86985e105f79b95d6bc918fb45ec7727_checksum.pdf"
// You can also use the hash method directly
Onym::hash(string $defaultFilename, string $extension, ?array $options = [])