Open source August 2026 /12 pages
Larameter

Larameter

Larameter

Larameter is credit metering, plans and quotas for Laravel. It sells an allowance per window and top-ups on the side, charges per action or per unit consumed, works out which plan an account is on, caps how many of something a plan allows, and stops a call before it spends what an account no longer has.

Nothing to do with AI in particular. The application this came from charges credits for creating a form, generating a document, running a poll, verifying an identity and sending an email, none of which involve a model. That is exactly why it is not part of an AI package: you should not have to install one to meter a form.

Written against version 1.0.

Why it exists

Every product that sells usage ends up writing the same four things, and getting the same two wrong.

The first is the balance. It starts as a SUM() over a usage table, which is correct right up to the day you sell a top-up. A purchase is not consumption, so it cannot be expressed as a sum of what was spent, and the aggregate has to become a stored column with an audit trail behind it. That is a migration, a backfill and an evening.

The second is the ceiling that nobody enforces. A plan says one seat, the usage screen shows one seat, and the invite form never checks it, because checking meant remembering to count first and the person writing the invite form was not thinking about billing. In the application this came from the cap was enforced for cases and forgotten for members, in the same codebase, for months.

Larameter's answer to the first is that the balance is a row and the deposits are a table, so it is both cheap to read and checkable. Its answer to the second is that a ceiling is a class, not a number the caller passes in:

$org->quota()->allows('members', 4);   // inviting four at once

Four tables

larameter_accounts    what does not expire: the plan, and credits bought on top
larameter_windows     what the plan has covered, per window, per account
larameter_deposits    credits in: purchases, gifts, refunds, adjustments
larameter_usage       credits out, append-only

Consumption does not live on the account, because an allowance is always an allowance per something, and how long that something lasts is your decision. See Windows and The data model.

Three doors

A trait goes into a class you did not write, and every name it claims there is a name that class can no longer use. So the three traits bring one method each, and everything hangs off those:

$org->plan() What was bought: the handle, the name, its features and its ceilings.
$org->credits() What has been spent, what things cost, charging, and topping up.
$org->quota() How many of something may exist, and whether there is room for more.

This is not decoration. An earlier version brought a meters(), which is a fatal error on any model that also uses Cashier's Billable, and the collision happens when the class is compiled, so the host application cannot catch it.

Requirements

  • PHP 8.2 and above
  • Laravel 12 and above

No other dependency. Cashier is detected and never required, so an application that sells credit bundles and no subscriptions installs nothing extra.

Where it is used

Larameter is the metering layer behind crowd.legal, where an organisation spends credits on documents, forms, polls, emails, identity verifications and model calls, against a session, weekly and monthly allowance at once.

How to read this

Chapters 2 and 3 get it running. Chapters 4 to 6 are the model: windows, plans, and where a plan comes from. Chapters 7 and 8 are pricing and charging, 9 is the quota side, which is a separate question, and 10 is what a usage screen needs. The last two are the tables and the full surface.

Released under the MIT license.