---
title: "Installation — Coupons for Laravel | Roundly"
description: "Install via Composer, publish and run the two migrations, and optionally publish the config and the translation strings."
url: https://roundly-consulting.com/open-source/docs/coupons-for-laravel/installation
language: en
---

[All packages](https://roundly-consulting.com/open-source.md)

[Coupons for Laravel](https://roundly-consulting.com/open-source/docs/coupons-for-laravel.md)

# Installation

Require the package with Composer, then publish and run the migrations. The service provider is auto-discovered, and money-for-laravel and package-toolkit-for-laravel come along as dependencies — no manual registration:

```bash
composer require roundly-consulting/coupons-for-laravel

php artisan vendor:publish --tag="coupons-migrations"
php artisan migrate
```

Migrations are publish-only: the package loads none itself, so running migrate before publishing creates nothing. Publishing copies coupons, then coupon\_redemptions, into database/migrations under timestamps one second apart, so the referenced table is always created first. Republishing overwrites the same files instead of duplicating them.

## Optional publishing

The config file is optional — every key has a default and all but one are env-backed. Publish it only to override:

```bash
php artisan vendor:publish --tag="coupons-config"
```

English and Slovak translations ship with the package. Publish them to reword the validation-rule and discount-type messages or to add another language:

```bash
php artisan vendor:publish --tag="coupons-translations"
```

| Tag | Publishes to |
| --- | --- |
| `coupons-migrations` | `database/migrations/<timestamp>_create_coupons_table.php, …_create_coupon_redemptions_table.php` |
| `coupons-config` | `config/coupons.php` |
| `coupons-translations` | `lang/vendor/coupons/{en,sk}/messages.php` |

## Before you migrate

If your redeemer models — usually User — use UUID or ULID primary keys, set coupons.key\_type before running the migration. It decides the type of the polymorphic redeemer column on coupon\_redemptions (see Redeemers & per-customer limits).

## At a glance

The package adds a Coupons section to Laravel’s about command:

```bash
php artisan about --only=coupons
```

- Model — the resolved coupon model class.
- Default currency — coupons.default\_currency, or INVALID: … with the reason when it is not a string.
- Redeemer tracking — ON or OFF.
- Generated codes — length and alphabet size only, e.g. “6 chars from a 36-symbol alphabet”. The alphabet itself is never printed; an unusable code.\* value shows as INVALID: … naming the key instead of failing the command.
- Route key — the column {coupon} binds by, or INVALID: … with the reason.

## Show your open-source love

This package is free and MIT-licensed. If it saves you time, a one-off donation or a Patreon membership keeps it maintained, tested and documented.

[More ways to support, including crypto](https://roundly-consulting.com/support-us.md)

By donating, you agree to our [donation terms](https://roundly-consulting.com/donation-terms.md).

[Support our open source work (opens in a new tab)](https://donate.stripe.com/dRmeVe8FX5PF1Qd9pXcEw00) [Join us on Patreon (opens in a new tab)](https://www.patreon.com/cw/roundly)

## Want this built into your product?

We integrate our packages into custom Laravel and AI builds. Tell us what you're working on and we'll reply within 48 hours.

[Get a quote in 48 hours](https://roundly-consulting.com/contact.md) [Browse all packages](https://roundly-consulting.com/open-source/docs/coupons-for-laravel.md)
