---
title: "Installation — Credits for Laravel | Roundly"
description: "Install via Composer, publish and run the publish-only migration, and optionally publish the config and translations."
url: https://roundly-consulting.com/open-source/docs/credits-for-laravel/installation
language: en
---

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

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

# Installation

Require the package. The service provider is auto-discovered, and its two Roundly dependencies — package-toolkit-for-laravel and money-for-laravel — install with it:

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

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

## Publish-only migration

The package never loads its migration itself. Publishing copies the credits migration into your database/migrations, where you own it — so a bare php artisan migrate before publishing creates nothing. The file is stamped with the current time, so it runs after your own tables; publishing again overwrites that same file in place.

The migration creates two tables: credits, the ledger, and credit\_locks, one small row per owner that serialises concurrent changes (see Overdraft protection).

If your creditable models use UUID or ULID keys, set CREDITS\_KEY\_TYPE before you migrate — see Key types & schema.

## A forward-only migration

Like every Roundly package migration, it has no down(): php artisan migrate:rollback does not drop the two tables, and the next migrate then fails on “table already exists”. The published copy is yours — to uninstall, drop credits and credit\_locks in a migration of your own, or add a down() to your copy.

## Config and translations

The config file is optional — the package works with zero host configuration. Publish it only to override a default:

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

The exception messages are translatable and ship in English and Slovak. Publish them to lang/vendor/credits to edit them or add locales:

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

The package exposes exactly three publish tags: credits-migrations, credits-config and credits-translations.

## Next steps

- Add the Creditable interface and the HasCredits trait to a model.
- Grant and deduct credits with modifyCredits().
- Split credit into named buckets if different kinds must never be spent against each other.

## 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/credits-for-laravel.md)
