Download the PHP package ridho/justsubs without Composer
On this page you can find all versions of the php package ridho/justsubs. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package justsubs
JustSubs
JustSubs is a solid, self-hosted subscription and billing infrastructure package for Laravel applications. It abstracts away the complexity of managing plans, polymorphic subscriptions, invoices, and payment processing while providing a built-in, standalone Tailwind CSS dashboard.
Features
- 🏗️ Domain Modeling: Complete abstraction for Plans, Subscriptions, Invoices, and Payments.
- 👥 Polymorphic Subscribers: Bind subscriptions to
User,Team,Company, or any Eloquent model. - 🎨 Built-in Dashboard: A ready-to-use Tailwind CSS control panel. No extra frontend compilation required for your host app.
- 🔌 Agnostic Payments: Extensible Payment Driver system. Start with manual payments and extend it later (e.g. Midtrans, Stripe).
- 📊 Analytics Overview: Automatically calculates active subscriptions, revenue, and normalized Estimated MRR (Monthly Recurring Revenue).
- 🛡️ Secure & Scalable: Race-condition safe with pessimistic locking, highly optimized queries avoiding N+1 memory exhaustion, and CSRF-protected dashboard endpoints.
Requirements
- PHP 8.2+
- Laravel 11.x
- Relational Database (MySQL, PostgreSQL, SQLite)
Installation
You can install the package via composer:
Publish the package configuration, migrations, and dashboard assets:
Run the database migrations:
Configuration
After running the install command, you can modify the configuration file located at config/justsubs.php.
Here you can change the table names (to prevent collisions with packages like Laravel Cashier) and customize the dashboard route prefix (defaults to /justsubs).
Dashboard Authorization
By default, the dashboard is only accessible in the local environment. To authorize users in production, register an authorization callback within the boot method of your App\Providers\AppServiceProvider.
Because it uses a closure, you have total freedom to define who gets access. Here are a few common examples:
1. Using an array of emails (Horizon style)
2. Using a Roles package (e.g. Spatie)
3. Using Laravel Gates
Since JustSubs uses Polymorphic subscribers, you can also define how to display the subscriber's name in the dashboard:
Adding HasSubscriptions
Add the HasSubscriptions trait to the Eloquent model that will be acting as the subscriber (e.g., your User or Team model).
Creating Plans
Plans can be created easily via the built-in Dashboard or programmatically using Eloquent.
Creating Subscriptions
To subscribe a user to a plan, use the SubscriptionManager service. Note that overlapping active subscriptions are blocked by default.
To check subscription status on your subscriber model:
Renewing
Subscriptions can be renewed via the dashboard or code. If the subscription is currently active, the renewal preserves the remaining time by adding the interval to the current ends_at. If it has expired, it restarts from now().
You can also manually extend a subscription (e.g. compensating a user for downtime):
Cancelling
You can cancel a subscription gracefully (access remains until the period ends) or immediately.
Invoices
To issue a bill for a new or existing subscription, use the BillingManager. This creates a collision-safe invoice number (e.g., INV-202608-00001).
Manual Payments
If a user pays via bank transfer or outside a gateway, you can mark the invoice as paid. This process automatically activates or renews the linked subscription safely inside a database transaction.
This can also be done visually by clicking "Mark as Paid (Manual)" on the Invoice Dashboard.
Dashboard
Navigate to your application's /justsubs URI to access the dashboard.
It includes:
- Analytics Overview: Active count, Outstanding revenue, MRR, Plan distribution.
- Plans: Full CRUD for plan management.
- Subscriptions: Table viewer, filtering, and manual operation interfaces (Renew, Extend, Cancel, Change Plan).
- Invoices: Billing records and manual payment processing.
- Payments: Immutable ledger of successful transactions.
Events
JustSubs dispatches eloquent events you can listen to in order to send emails or run webhook synchronizations:
Ridho\JustSubs\Events\PaymentReceivedRidho\JustSubs\Events\InvoicePaidRidho\JustSubs\Events\SubscriptionCreatedRidho\JustSubs\Events\SubscriptionActivatedRidho\JustSubs\Events\SubscriptionRenewedRidho\JustSubs\Events\SubscriptionExtendedRidho\JustSubs\Events\SubscriptionPlanChangedRidho\JustSubs\Events\SubscriptionCancelledRidho\JustSubs\Events\SubscriptionExpired
Payment Driver Extension
JustSubs operates on a flexible PaymentDriver contract. You can integrate Midtrans, Stripe, or Xendit by extending the registry without modifying core code.
- Implement
\Ridho\JustSubs\Contracts\PaymentDriver. - Register it in your
AppServiceProvider:
Testing
The test suite spans across unit tests and HTTP feature tests, enforcing behavior with SQLite memory databases. All operations check for Race Conditions, Type Casting, and Duplicate Subscriptions.
Security
If you discover any security related issues, please create an issue or contact the author directly. Do not expose vulnerability details openly on public trackers. Built-in securities:
- CSRF Protection: Verified on all state-changing dashboard routes.
- Idempotency Check: Duplicate payments to an already-paid invoice are instantly rejected with
PaymentFailedException. - Pessimistic Locking: Parallel payment callbacks lock the DB row (
lockForUpdate()) to prevent race conditions.
Upgrade Notes
No prior versions exist. The first release candidate is v0.1.0. Wait for the 1.0.0 battle-tested release before massive production adoption.
License
The MIT License (MIT).
Contributing
If you wish to contribute to JustSubs, you can run the following commands to ensure your code meets the quality gate requirements: