Skip to content
v1.0.0-beta · Laravel 10–13

Subscription state,
done right.

Tashil (تسهيل) is a Laravel package for subscription and feature management. It owns the plan catalog, feature gating, atomic usage counters, trials, an immutable event log, and the billing lifecycle — without ever charging a card.

$composer require foysal50x/tashil
BillingExample.php
use Foysal50x\Tashil\Facades\Tashil;

// Define a plan and attach features
Tashil::package('pro')->name('Pro')->price(29)->monthly()
    ->trialDays(14)
    ->feature($apiCalls, value: '10000')
    ->feature($aiTokens, value: '0.001')   // metered: price per unit
    ->create();

// Subscribe — a priced plan stays Pending until its
// first invoice is paid, then activates automatically.
$sub = Tashil::subscription()->subscribe($user, $pro, withTrial: true);

// Gate access and meter usage — atomically, race-safe.
if ($user->useFeature('api-calls')) {
    // within quota
}

Tashil owns

Plan definitions, subscription state, feature gating, usage counters, trial lifecycle, scheduled transitions, invoice issuance, and the activation / dunning / reactivation state machine.

Your app owns

Money movement — card capture, the retry charge during dunning, refunds, gateway reconciliation, and the wallet that funds metered features. Tashil issues the bill; you move the money.

Everything a subscription needs

Production-ready primitives that compose cleanly — each one documented with complete, copy-paste examples.

Plans & feature gating

Five feature types — boolean, limit, consumable, enum, and metered — defined once and attached per plan with a fluent builder.

Atomic usage counters

Limit increments run as a single conditional UPDATE. Two concurrent callers can never both pass the cap. No read-modify-write races.

First-class trials

Start, warn, convert, and expire — tracked with four timestamps and strict on-trial semantics, driven by idempotent scheduled jobs.

Billing lifecycle

A state machine for activate → renew → dunning → reactivate, with proration on in-place plan changes. Tashil owns the state; your app moves the money.

Metered billing

Per-unit charges delegated to a host MeteredBilling implementation. Charge-before-write ordering with caller-supplied idempotency keys.

Immutable event log

Every transition is appended with a strictly monotonic sequence number — a complete, replayable, point-in-time audit trail.

Analytics

MRR, churn, trial conversion, and revenue — cross-database aggregates with no raw SQL.

Middleware & Blade

subscribed, plan, and feature gates for routes and views, with a pluggable subscriber resolver.

Runs anywhere

Tested on SQLite, MySQL 8, and PostgreSQL 16 across Laravel 10–13 and PHP 8.2–8.5.

Ready in minutes

Install, publish the config and migration, make your model Subscribable, and you have a full subscription system. The guide walks you through every step.