Download the PHP package miladtech/laravel-subscriptions without Composer
On this page you can find all versions of the php package miladtech/laravel-subscriptions. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download miladtech/laravel-subscriptions
More information about miladtech/laravel-subscriptions
Files in miladtech/laravel-subscriptions
Package laravel-subscriptions
Short Description Milad Tech Subscriptions is a flexible plans and subscription management system for Laravel, with the required tools to run your SAAS like services efficiently. It's simple architecture, accompanied by powerful underlying to afford solid platform for your business.
License MIT
Homepage https://milad-tech.com
Informations about the package laravel-subscriptions
MiladTech Subscriptions
MiladTech Subscriptions is a flexible plans and subscription management system for Laravel, with the required tools to run your SAAS like services efficiently. It's simple architecture, accompanied by powerful underlying to afford solid platform for your business.
Supports Laravel 11, 12 and 13 on PHP 8.2+, fully self-contained, with lifecycle events, grace periods, suspension, safe concurrent usage tracking, and a complete test suite.
Considerations
- Payments are out of scope for this package. Listen to the lifecycle events (e.g.
SubscriptionCanceled) to integrate your payment provider. - You may extend the core models when you need to override logic behind helper methods like
renew(),cancel(), etc.
Installation
Migrations load automatically. Optionally publish resources:
Upgrading from v7? Read UPGRADE.md.
Usage
Add subscriptions to your model
Use the HasPlanSubscriptions trait on any subscriber model (usually User):
Create a plan with features
Feature value semantics: "true" = enabled/unlimited · "false", "0", empty = disabled · numeric = countable limit · anything else = descriptive value (enabled).
Subscribe
Plans without a trial get trial_ends_at = null; with a trial, the paid period starts when the trial ends. Inactive plans and plans at their active_subscribers_limit throw (InactivePlanException, PlanSubscribersLimitReachedException). For admin/internal flows that attach private (inactive) plans manually, skip those checks:
Check status
Feature usage — safe by design
All writes run in a transaction with a row lock, so concurrent requests can never exceed a limit.
recordFeatureUsage throws FeatureNotFoundException (unknown feature), FeatureUsageExceededException (limit reached) or SubscriptionException (inactive subscription) — catch them or gate with canUseFeature(). All package exceptions extend MiladTech\Subscriptions\Exceptions\SubscriptionException.
Resettable features (resettable_period/resettable_interval) reset automatically when their window elapses, aligned to the subscription start — even when several windows pass without activity.
Renew
Early renewal extends the current period from ends_at — subscribers never lose paid time — and keeps usage. Renewal after expiry starts a fresh period from now and clears usage. Renewing also reverts any scheduled cancellation.
Cancel / uncancel
Suspend / resume
Change plan
Usage is migrated to the new plan's features by slug: shared features keep their usage (limits may shrink or grow naturally), removed features lose their usage. Different billing frequency starts a new period today. Pass changePlan($newPlan, syncUsage: false) to wipe usage instead.
changePlan accepts inactive plans on purpose — changing an existing subscriber's plan is an internal/admin operation, and inactive plans are commonly private/custom plans attached manually. is_active only gates new public subscriptions.
Events
Every lifecycle change dispatches an event you can listen to:
SubscriptionCreated, SubscriptionRenewed, SubscriptionCanceled, SubscriptionUncanceled, SubscriptionSuspended, SubscriptionResumed, SubscriptionPlanChanged, SubscriptionExpired, SubscriptionTrialEnded, FeatureUsageRecorded, FeatureUsageReduced — all under MiladTech\Subscriptions\Events.
SubscriptionExpired and SubscriptionTrialEnded are fired (exactly once per subscription, grace-period aware) by the checker command. Schedule it in routes/console.php:
Scopes
Models & config
Override table names or swap in your own models via the published config file (config/miladtech.subscriptions.php). Slugs are Persian-friendly (via pishran/laravel-persian-slug), and name/description are translatable (via spatie/laravel-translatable):
Subscription slugs are unique per subscriber (every user can own a subscription slugged main), and feature slugs are unique per plan (so plans can share feature slugs — that's what makes plan changes migrate usage).
Testing
CI runs the suite against every supported PHP/Laravel combination.
License
This software is released under The MIT License (MIT).
All versions of laravel-subscriptions with dependencies
illuminate/console Version ^11.0 || ^12.0 || ^13.0
illuminate/database Version ^11.0 || ^12.0 || ^13.0
illuminate/support Version ^11.0 || ^12.0 || ^13.0
spatie/eloquent-sortable Version ^4.0
spatie/laravel-sluggable Version ^3.7
spatie/laravel-translatable Version ^6.5
pishran/laravel-persian-slug Version ^2.2.2