PHPackages                             rm/unique - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. rm/unique

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

rm/unique
=========

Library for generating unique file names.

v0.1.0(11y ago)11951MITPHPPHP &gt;=5.4

Since Apr 26Pushed 11y ago1 watchersCompare

[ Source](https://github.com/romanmatyus/Unique)[ Packagist](https://packagist.org/packages/rm/unique)[ Docs](https://github.com/romanmatyus/Unique)[ RSS](/packages/rm-unique/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (3)Versions (2)Used By (0)

Unique
======

[](#unique)

[![Build Status](https://camo.githubusercontent.com/c53905bb5ea664121e91a3ffdd521ab792a1d37058ef3812ce572ff3ba073fc1/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f726f6d616e6d61747975732f556e697175652f6261646765732f6275696c642e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/romanmatyus/Unique/build-status/master)[![Code Quality](https://camo.githubusercontent.com/95d4815f8a754af121e1ac4f709d8e3817b2accaa843e99710713954f5e04810/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f726f6d616e6d61747975732f556e697175652f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/romanmatyus/Unique/)[![Code Coverage](https://camo.githubusercontent.com/672d36fa5673363e73234aec9ca70dbc4fb29b523cb96c9fa9e201635b1a5050/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f726f6d616e6d61747975732f556e697175652f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/romanmatyus/Unique/)[![Packagist](https://camo.githubusercontent.com/1e574786010b683ca596d00ed78e9499c79fef13c208d5dbace4c6bd99b041b8/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f726d2f756e697175652e737667)](https://packagist.org/packages/rm/unique)

Uniqe is simple library for generating unique filenames in directories.

Requirements
------------

[](#requirements)

Unique requires PHP 5.4 or later.

Installation
------------

[](#installation)

The best way to install Unique is use [Composer](http://getcomposer.org) package [`rm/unique`](https://packagist.org/packages/rm/unique) or manual download the latest ZIP package from [GitHub](https://github.com/romanmatyus/Unique/archive/master.zip).

```
$ composer require rm/unique

```

Example
-------

[](#example)

I need upload file `something.png` into directory `/images`.

If it is necessary to not overwrite existing files, you need to generate unique filenames.

**Now it's simple!**

```
$filename = Unique::get('something.png', '/images'); // return 'something.png'
```

And what if directory contains files `something.png` and for example, also `something-1.png`?

Returns `something-2.png`!

`Unique::get()` automatic generate filename in format `.` and check if exists in specified directory. If is unique, return it.

API
---

[](#api)

### get()

[](#get)

Method `get()` has two parameters:

- `string` `$filename` Name of file
- `string` `$dir` Directory where will be file saved

Return

- `string` Output filename

### $separator

[](#separator)

Default `separator` of filename and order it's `-`. It's possible change it, for example:

```
Unique::$separator = '|';
```

Contributing
------------

[](#contributing)

- Use it!
- Write bug reports of ideas into [Issue tracker](https://github.com/romanmatyus/Unique/issues).
- Fork repos and send pull requests with number of issue, source code and tests.

Contact
-------

[](#contact)

Roman Mátyus

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

4040d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1110294?v=4)[Roman Mátyus](/maintainers/romanmatyus)[@romanmatyus](https://github.com/romanmatyus)

---

Top Contributors

[![romanmatyus](https://avatars.githubusercontent.com/u/1110294?v=4)](https://github.com/romanmatyus "romanmatyus (10 commits)")

---

Tags

uniquefilenamesrm

### Embed Badge

![Health badge](/badges/rm-unique/health.svg)

```
[![Health](https://phpackages.com/badges/rm-unique/health.svg)](https://phpackages.com/packages/rm-unique)
```

###  Alternatives

[joegreen0991/hyperloglog

A hyper log log with min hash data structure library, for counting cardinalities. Union and intersection capable

2116.5k](/packages/joegreen0991-hyperloglog)[infocyph/uid

UUID (RFC 4122 + Unofficial/Draft), ULID, Snowflake ID, Sonyflake ID, TBSL (library exclusive) generator!

105.1k](/packages/infocyph-uid)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
