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. ryantxr/coupon-code

ActiveLibrary

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 today

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 40% 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

2620d 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

[whitecube/lingua

A PHP language codes converter, from and to the most common formats (ISO, W3C, PHP and human-readable names).

431.1M11](/packages/whitecube-lingua)[enygma/gauth

PHP library to generate codes compatible with the Google Authenticator clients

75128.1k1](/packages/enygma-gauth)[atelierdisko/coupon_code

PHP library to generate and validate coupon code strings.

60187.8k2](/packages/atelierdisko-coupon-code)[io238/laravel-iso-countries

Ready-to-use Laravel models and relations for country (ISO 3166), language (ISO 639-1), and currency (ISO 4217) information with multi-language support.

5358.7k](/packages/io238-laravel-iso-countries)[frittenkeez/laravel-vouchers

Voucher system for Laravel 9+

5818.8k1](/packages/frittenkeez-laravel-vouchers)[juanparati/iso-codes

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

17139.2k](/packages/juanparati-iso-codes)

PHPackages © 2026

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