2017 © Pedro Peláez
 

library unique

Library for generating unique file names.

image

rm/unique

Library for generating unique file names.

  • Sunday, April 26, 2015
  • by romanmatyus
  • Repository
  • 1 Watchers
  • 0 Stars
  • 120 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

Unique

Build Status Code Quality Code Coverage Packagist, (*1)

Uniqe is simple library for generating unique filenames in directories., (*2)

Requirements

Unique requires PHP 5.4 or later., (*3)

Installation

The best way to install Unique is use Composer package rm/unique or manual download the latest ZIP package from GitHub., (*4)

$ composer require rm/unique

Example

I need upload file something.png into directory /images., (*5)

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

Now it's simple!, (*7)

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

And what if directory contains files something.png and for example, also something-1.png?, (*8)

Returns something-2.png!, (*9)

Unique::get() automatic generate filename in format <filename><separator><order>.<extension> and check if exists in specified directory. If is unique, return it., (*10)

API

get()

Method get() has two parameters:, (*11)

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

Return, (*12)

  • string Output filename

$separator

Default separator of filename and order it's -. It's possible change it, for example:, (*13)

Unique::$separator = '|';

Contributing

  • Use it!
  • Write bug reports of ideas into Issue tracker.
  • Fork repos and send pull requests with number of issue, source code and tests.

Contact

Roman Mátyus romanmatyus@romiix.org, (*14)

The Versions

26/04 2015

dev-master

9999999-dev https://github.com/romanmatyus/Unique

Library for generating unique file names.

  Sources   Download

MIT

The Requires

  • php >=5.4

 

The Development Requires

unique rm filenames

26/04 2015

v0.1.0

0.1.0.0 https://github.com/romanmatyus/Unique

Library for generating unique file names.

  Sources   Download

MIT

The Requires

  • php >=5.4

 

The Development Requires

unique rm filenames