PHPackages                             amestsantim/voucherator - 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. amestsantim/voucherator

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

amestsantim/voucherator
=======================

A generic PHP package that can generate all sorts of random voucher/coupon codes. Laravel compatible.

2.2.0(4y ago)342622MITPHPPHP ^7.3|^8.0

Since Feb 22Pushed 4y ago2 watchersCompare

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

READMEChangelog (6)Dependencies (1)Versions (9)Used By (0)

Voucherator
===========

[](#voucherator)

[![Total Downloads](https://camo.githubusercontent.com/8203541dca644830f57945513f8b8731afb00a379e285c2c901961aedd4d1d24/68747470733a2f2f706f7365722e707567782e6f72672f616d65737473616e74696d2f766f756368657261746f722f646f776e6c6f616473)](https://packagist.org/packages/amestsantim/voucherator) [![License](https://camo.githubusercontent.com/9c90bb8025e1d9a482ef0395fddba925d60623600a0df2d39100b7d993d506e7/68747470733a2f2f706f7365722e707567782e6f72672f616d65737473616e74696d2f766f756368657261746f722f6c6963656e7365)](https://packagist.org/packages/amestsantim/voucherator)

The only voucher (alphanumeric code) generator you will ever need for PHP.
Voucherator has a fluent Generator class that can generate various types of random alphanumeric codes. The package also includes a Transformer class that you can use to apply some transformations to the generated vouchers. You can use it to generate passwords, pass codes, keys, vouchers, coupons, tickets, tokens etc.

Prerequisites
-------------

[](#prerequisites)

This package uses PHP 7's `random_int()` function which generates cryptographic random integers that are suitable for use where unbiased results are critical, such as when shuffling a deck of cards for a poker game.

The sources of randomness used for this function are as follows and if your machine does not provide one of these, you will not be able to use this package.

- On Windows, [» **CryptGenRandom()**](https://msdn.microsoft.com/en-us/library/windows/desktop/aa379942(v=vs.85).aspx) will always be used. As of PHP 7.2.0, the [» CNG-API](https://docs.microsoft.com/en-us/windows/desktop/SecCNG/cng-portal) will always be used instead.
- On Linux, the [» getrandom(2)](http://man7.org/linux/man-pages/man2/getrandom.2.html) syscall will be used if available.
- On other platforms, /dev/urandom will be used.
- If none of the aforementioned sources are available, then an [Exception](http://php.net/manual/en/class.exception.php) will be thrown. (caught and supressed by this package)

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

[](#installation)

### Via Composer

[](#via-composer)

This package can be installed easily with composer - just require the `amestsantim/voucherator` package from the command line.

```
composer require amestsantim/voucherator

```

Alternatively, you can manually add the voucherator package to your `composer.json` file and then run `composer install` from the command line as follows:

```
{
    "require": {
        "amestsantim/voucherator": "~2.1"
    }
}

```

```
composer install

```

You can use it in your PHP code like this:

```
