PHPackages                             ajaxray/short-code - 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. [Logging &amp; Monitoring](/categories/logging)
4. /
5. ajaxray/short-code

ActiveLibrary[Logging &amp; Monitoring](/categories/logging)

ajaxray/short-code
==================

ShortCode generator for PHP. Create short, reversible or random, hash like codes.

v1.1.0(9y ago)2977.1k—1%10[3 PRs](https://github.com/ajaxray/short-code/pulls)2MITPHPPHP &gt;=5.3.0

Since Oct 24Pushed 4y ago3 watchersCompare

[ Source](https://github.com/ajaxray/short-code)[ Packagist](https://packagist.org/packages/ajaxray/short-code)[ Docs](http://github.com/ajaxray/short-code)[ RSS](/packages/ajaxray-short-code/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (1)Versions (3)Used By (2)

ShortCode
=========

[](#shortcode)

[![SensioLabsInsight](https://camo.githubusercontent.com/03a256c03c6f9e702e2d80215989c099b8fc30e2f6bb1b9e77f0b2fdc685b2bf/68747470733a2f2f696e73696768742e73656e73696f6c6162732e636f6d2f70726f6a656374732f38323534303632652d353338612d343636372d616135362d3932306532393362656635612f736d616c6c2e706e67)](https://insight.sensiolabs.com/projects/8254062e-538a-4667-aa56-920e293bef5a)[![Build Status](https://camo.githubusercontent.com/c4cd69860694147814dfcaaacdd6ba774223d509da64128fb3186db36417f09f/68747470733a2f2f7472617669732d63692e6f72672f616a61787261792f73686f72742d636f64652e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/ajaxray/short-code)[![Coverage Status](https://camo.githubusercontent.com/22bebaa0cd802ad041f737a12135ce530abf5c3cfcd226238f1cd7056542506a/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f616a61787261792f73686f72742d636f64652f62616467652e7376673f6272616e63683d6d617374657226736572766963653d676974687562)](https://coveralls.io/github/ajaxray/short-code?branch=master)[![Latest Stable Version](https://camo.githubusercontent.com/8c2ba2ae4b2906abaa235b6d3642fb46ec4ea7420e9696ceb2948515beb7caa3/68747470733a2f2f706f7365722e707567782e6f72672f616a61787261792f73686f72742d636f64652f762f737461626c65)](https://packagist.org/packages/ajaxray/short-code)[![Total Downloads](https://camo.githubusercontent.com/b7015ba944796b9b69dbcbfdf8091c07c44b0222fc1690c3224bfee086db9486/68747470733a2f2f706f7365722e707567782e6f72672f616a61787261792f73686f72742d636f64652f646f776e6c6f616473)](https://packagist.org/packages/ajaxray/short-code)[![License](https://camo.githubusercontent.com/4a7b73531e99aa18ac8856ce2c3f5399d5044f64666ece2dfb8a80bf983241a5/68747470733a2f2f706f7365722e707567782e6f72672f616a61787261792f73686f72742d636f64652f6c6963656e7365)](https://packagist.org/packages/ajaxray/short-code)

ShortCode generator for PHP. Create short, hash like codes. Codes can be random or reversible. Output format is customizable (see the list below).
You can generate random string code of your desired character length, e.g. 4, 6, 8 ... up to 20.
Also, you can generate reversible codes from numbers. It's useful when you'll need to trace the original number from a reference code string.

Can be used for generating small reference codes, tiny URLs or any other purpose.

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

[](#installation)

Install the latest version with

```
$ composer require ajaxray/short-code

```

Supported Output and Conversion Formats
---------------------------------------

[](#supported-output-and-conversion-formats)

- `ShortCode\Code::FORMAT_ALNUM` : (Default) Alphanumaric characters. includes 0-9, a-z and A-Z
- `ShortCode\Code::FORMAT_ALNUM_CAPITAL` : Alphanumaric characters. includes 0-9 and A-Z
- `ShortCode\Code::FORMAT_ALNUM_SMALL` : Alphanumaric characters. includes 0-9 and a-z
- `ShortCode\Code::FORMAT_CHAR_CAPITAL` : Capital letter characters. includes only A-Z
- `ShortCode\Code::FORMAT_CHAR_SMALL` : Small letter characters. includes only a-z
- `ShortCode\Code::FORMAT_NUMBER` : Numbers. includes only 0-9. Can be used for random number generation

Generating Random Code
----------------------

[](#generating-random-code)

```
