PHPackages                             mattgorle/filename-suffixer - 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. mattgorle/filename-suffixer

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

mattgorle/filename-suffixer
===========================

Ensures unique filenames by adding a numeric suffix

0.2.1(4y ago)0903↓11.8%mitPHPPHP ^7.2|^8.0

Since Aug 14Pushed 4y ago1 watchersCompare

[ Source](https://github.com/mattgorle/filename-suffixer)[ Packagist](https://packagist.org/packages/mattgorle/filename-suffixer)[ RSS](/packages/mattgorle-filename-suffixer/feed)WikiDiscussions main Synced today

READMEChangelogDependencies (1)Versions (4)Used By (0)

Filename Suffixer
=================

[](#filename-suffixer)

Ensures that filenames are unique by appending a suffix to the filename.

If a file with `$filename` does not already exist, then the original filename is offered instead of an altered one.

### Examples

[](#examples)

For a file named `test_file.txt`, `FilenameSuffixer::suffix` will return:

- `test_file.txt` if the file does not exist
- `test_file-1.txt` if a file called `test_file.txt` already exists
- `test_file-2.txt` if files called `test_file.txt` and `test_file-1.txt` already exist
- etc...

Versioning
----------

[](#versioning)

This project follows semantic versioning.

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

[](#installation)

```
composer require mattgorle/filename-suffixer
```

Usage
-----

[](#usage)

```
use Gorle\FilenameSuffixer\FilenameSuffixer;

$filename = 'your_file.jpg'

$safeFilename = FilenameSuffixer::suffix($filename);
// - your_file.jpg if the file does not already exist
// - your_file-1.jpg if your_file.jpg already exists
// - your_file-2.jpg if your_file-1.jpg already exists
// - etc...
```

Customising behaviour
---------------------

[](#customising-behaviour)

I have tried to select sensible defaults, but you can modify several parameters to suit your individual use case by changing the value of the static properties on `FilenameSuffixer`.

You can customise the following:

OptionDefault ValuePropertyFile extension separator`.`FilenameSuffixer::$extensionSeparatorSuffix separator`-`FilenameSuffixxer::$suffixSeparatorPath separator`/`FilenameSuffixer::$pathSeparatorSuffix starting number`1`FilenameSuffixer::$suffixStartsAt### Examples

[](#examples-1)

```
use Gorle\FilenameSuffixer\FilenameSuffixer;

FilenameSuffixer::$extensionSeparator = '_';
FilenameSuffixer::$pathSeparator = ':';
FilenameSuffixer::$suffixStartsAt = 31;
FilenameSuffixer::$suffixSeparator = '_';
```

Resetting the suffixer after changing defaults
----------------------------------------------

[](#resetting-the-suffixer-after-changing-defaults)

> Help, I've changed loads of stuff and now I can't find my way back!!! 😭

Simply call `FilenameSuffixer::reset()` and the initial defaults will be reinstated.

Honestly, I don't know if this is going to be a useful feature - it came up in testing and it feels more like a consequence of implementing this as a static class. Probably needs some thought!

###  Health Score

26

—

LowBetter than 41% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community7

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

Every ~1 days

Total

3

Last Release

1783d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/800bbafc0b877dabae8194c8517a144bf1adcadffad207d8292256d21e9c87c2?d=identicon)[mattgorle](/maintainers/mattgorle)

---

Top Contributors

[![mattgorle](https://avatars.githubusercontent.com/u/3032672?v=4)](https://github.com/mattgorle "mattgorle (23 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/mattgorle-filename-suffixer/health.svg)

```
[![Health](https://phpackages.com/badges/mattgorle-filename-suffixer/health.svg)](https://phpackages.com/packages/mattgorle-filename-suffixer)
```

###  Alternatives

[jetbrains/phpstorm-stubs

PHP runtime &amp; extensions header files for PhpStorm

1.4k32.7M83](/packages/jetbrains-phpstorm-stubs)[localheinz/diff

Fork of sebastian/diff for use with ergebnis/composer-normalize

4741.1M9](/packages/localheinz-diff)[symfony/ai-agent

PHP library for building agentic applications.

32870.1k107](/packages/symfony-ai-agent)[yahnis-elsts/admin-notices

A utility library for WordPress plugins that makes it easier to create admin notices. Supports persistently dismissible notices.

311.8k](/packages/yahnis-elsts-admin-notices)

PHPackages © 2026

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