PHPackages                             ryantxr/coupon-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. [Utility &amp; Helpers](/categories/utility)
4. /
5. ryantxr/coupon-code

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

ryantxr/coupon-code
===================

Generates coupon codes.

1.0.0(7y ago)151DBADPHPPHP &gt;=7.1

Since Jan 18Pushed 7y ago1 watchersCompare

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

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

Coupon Code Generator
=====================

[](#coupon-code-generator)

This is a flexible coupon code generator.

A 'Coupon Code' is made up of letters and numbers grouped into 4 character 'parts'. For example, a 3-part code might look like this:

1K7Q-CTFM-LMTC

Coupon Codes are random codes which are easy for the recipient to type accurately into a web form. An example application might be to print a code on a letter to a customer who would then enter the code as part of the registration process for web access to their account.

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

[](#installation)

```
composer require ryantxr/coupon-code

```

Static Usage
------------

[](#static-usage)

```
\Ryantxr\CouponCode\Generator::generate(); // generate a code
\Ryantxr\CouponCode\Generator::generate(true); // generate a lowercase code
$bytes = random_bytes(16);
\Ryantxr\CouponCode\Generator::generate(true, $bytes); // generate a lower case code and pass in the random bytes
\Ryantxr\CouponCode\Generator::init(['numberOfSegments' => 5, 'segmentLength' => 4])->generateCode(); // generate a code
```

Use as an object
----------------

[](#use-as-an-object)

```
$codeGenerator = new \Ryantxr\CouponCode\Generator();
$codeGenerator = new \Ryantxr\CouponCode\Generator(['numberOfSegments' => 5, 'segmentLength' => 4]);

$code = $codeGenerator->generateCode();
$code = $codeGenerator->generateCode(true); // generate a lowercase code
$code = $codeGenerator->generateCode(true, $randomBytes); // generate a lowercase code, passing in the random bytes
```

See also
--------

[](#see-also)

[perl](https://github.com/grantm/Algorithm-CouponCode)

[NodeJS](https://www.npmjs.com/package/coupon-code)

[Ruby](https://rubygems.org/gems/coupon_code/versions/0.0.1) [https://rubygems.org/gems/coupon\_code/versions/0.0.1](https://rubygems.org/gems/coupon_code/versions/0.0.1)

[php](https://github.com/atelierdisko/coupon_code) [https://github.com/atelierdisko/coupon\_code](https://github.com/atelierdisko/coupon_code)

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity55

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

2672d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/570a13e97922f5c09d9dc6517329a2898a1097bf85e0f88ccea77c8b0d429f4c?d=identicon)[ryantxr](/maintainers/ryantxr)

---

Top Contributors

[![ryantxr](https://avatars.githubusercontent.com/u/12485311?v=4)](https://github.com/ryantxr "ryantxr (5 commits)")

---

Tags

codescoupon

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/ryantxr-coupon-code/health.svg)

```
[![Health](https://phpackages.com/badges/ryantxr-coupon-code/health.svg)](https://phpackages.com/packages/ryantxr-coupon-code)
```

###  Alternatives

[frittenkeez/laravel-vouchers

Voucher system for Laravel 9+

5819.9k2](/packages/frittenkeez-laravel-vouchers)[juanparati/iso-codes

A PHP library that provides ISO codes, currencies, languages, timezones and additional geopolitical information

17146.4k](/packages/juanparati-iso-codes)[smile/module-multi-coupon

Extension of Magento2 Sales Rule to allow multiple coupon usage.

102.9k](/packages/smile-module-multi-coupon)

PHPackages © 2026

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