PHPackages                             mahbub/laravel-saas-kit - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Payment Processing](/categories/payments)
4. /
5. mahbub/laravel-saas-kit

ActiveLibrary[Payment Processing](/categories/payments)

mahbub/laravel-saas-kit
=======================

A complete SaaS boilerplate package for Laravel — Multi-tenancy, Subscriptions, Feature Flags, and BD/International Payment Gateways.

v1.0.0(yesterday)00MITPHPPHP ^8.1

Since Jun 8Pushed yesterdayCompare

[ Source](https://github.com/mahbubur508/laravel-saas-kit)[ Packagist](https://packagist.org/packages/mahbub/laravel-saas-kit)[ Docs](https://github.com/mahbub/laravel-saas-kit)[ RSS](/packages/mahbub-laravel-saas-kit/feed)WikiDiscussions main Synced yesterday

READMEChangelog (1)Dependencies (5)Versions (2)Used By (0)

🚀 Laravel SaaS Kit
==================

[](#-laravel-saas-kit)

[![Latest Version on Packagist](https://camo.githubusercontent.com/759f76117efd4b222a3e12db3a91b91918d441b4fb83562088c2eb9c09c64df1/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d61686275622f6c61726176656c2d736161732d6b69742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/mahbub/laravel-saas-kit)[![Total Downloads](https://camo.githubusercontent.com/69886bb61bd0eb80b96586c258fd62aa743458bc62a0f460393b8011bb38d016/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d61686275622f6c61726176656c2d736161732d6b69742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/mahbub/laravel-saas-kit)[![License: MIT](https://camo.githubusercontent.com/fdf2982b9f5d7489dcf44570e714e3a15fce6253e0cc6b5aa61a075aac2ff71b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d79656c6c6f772e737667)](https://opensource.org/licenses/MIT)

A complete, framework-agnostic SaaS boilerplate package for Laravel. Drop it into any Laravel app and get **multi-tenancy**, **subscription billing**, **feature flags**, and **usage limits** — all in one package.

Supports both **international (Stripe)** and **Bangladeshi payment gateways (bKash, Nagad)** out of the box.

---

✨ Features
----------

[](#-features)

- 🏢 **Multi-tenancy** — Single DB (column isolation) or Multi DB (per-tenant database)
- 💳 **Payment Gateways** — Stripe, bKash, Nagad with a unified interface
- 📦 **Subscription Plans** — Free/Pro/Enterprise with trial periods and grace periods
- 🚦 **Feature Flags** — Per-plan feature toggling
- 📊 **Usage Limits** — Track and enforce limits (users, projects, API calls, storage)
- 🔔 **Events** — PaymentSucceeded, PaymentFailed, UsageLimitReached
- 🔌 **Extensible** — Override any model or gateway with your own

---

📋 Requirements
--------------

[](#-requirements)

- PHP 8.1+
- Laravel 10 or 11

---

📦 Installation
--------------

[](#-installation)

```
composer require mahbub/laravel-saas-kit
```

### Publish config and migrations

[](#publish-config-and-migrations)

```
php artisan vendor:publish --tag=saas-kit-config
php artisan vendor:publish --tag=saas-kit-migrations
php artisan migrate
```

---

⚙️ Configuration
----------------

[](#️-configuration)

Open `config/saas-kit.php` and configure your setup:

```
'tenancy' => [
    'driver'      => 'single',      // 'single' or 'multi'
    'identify_by' => 'subdomain',   // 'subdomain', 'domain', 'header', 'path'
],

'billing' => [
    'default_gateway' => 'stripe',  // 'stripe', 'bkash', 'nagad'
],
```

Add to your `.env`:

```
# Tenancy
SAAS_TENANCY_DRIVER=single
SAAS_IDENTIFY_BY=subdomain
APP_DOMAIN=yourapp.com

# Stripe
STRIPE_KEY=pk_live_xxx
STRIPE_SECRET=sk_live_xxx
STRIPE_WEBHOOK_SECRET=whsec_xxx

# bKash
BKASH_APP_KEY=your_app_key
BKASH_APP_SECRET=your_app_secret
BKASH_USERNAME=your_username
BKASH_PASSWORD=your_password
BKASH_SANDBOX=false

# Nagad
NAGAD_MERCHANT_ID=your_merchant_id
NAGAD_MERCHANT_NUMBER=your_number
NAGAD_PUBLIC_KEY=your_public_key
NAGAD_PRIVATE_KEY=your_private_key
NAGAD_SANDBOX=false
```

---

🚀 Usage
-------

[](#-usage)

### 1. Tenant-Scoped Models

[](#1-tenant-scoped-models)

Add the `BelongsToTenant` trait to any model. The `tenant_id` column will be auto-set and all queries will be automatically scoped:

```
use Mahbub\SaasKit\Concerns\BelongsToTenant;

class Project extends Model
{
    use BelongsToTenant;
}

// Automatically filtered by current tenant
$projects = Project::all();

// Query without scope (admin use)
$allProjects = Project::withoutTenantScope()->get();

// Query for specific tenant
$projects = Project::forTenant($tenant)->get();
```

### 2. Identify Tenant in Routes

[](#2-identify-tenant-in-routes)

Add the middleware to your tenant routes:

```
Route::middleware('identify.tenant')->group(function () {
    Route::get('/dashboard', DashboardController::class);
    // ...
});
```

### 3. Subscriptions

[](#3-subscriptions)

```
use Mahbub\SaasKit\Facades\SaasKit;

// Subscribe tenant to a plan
SaasKit::subscribeTo(plan: 'pro', gateway: 'bkash');

// Check subscription
if ($tenant->subscribed('pro')) {
    // tenant is on pro plan
}

// Cancel
SaasKit::cancelSubscription();
```

### 4. Feature Flags

[](#4-feature-flags)

```
// Check if tenant's plan includes a feature
if (SaasKit::hasFeature('advanced_reports')) {
    return view('reports.advanced');
}

return view('reports.basic');
```

### 5. Usage Limits

[](#5-usage-limits)

```
// Check if within limit (doesn't consume)
if (SaasKit::withinLimit('projects', count: 1)) {
    // can create a project
}

// Check and consume in one step (throws if exceeded)
try {
    SaasKit::consume('projects');
    Project::create([...]);
} catch (UsageLimitExceededException $e) {
    return response()->json(['error' => 'Project limit reached. Please upgrade.'], 403);
}
```

### 6. Payments

[](#6-payments)

```
// Initiate a Stripe payment
$result = SaasKit::billing('stripe')->initiate($tenant, 29.99);
// Returns: ['client_secret' => '...']  (use with Stripe.js)

// Initiate a bKash payment (redirect-based)
$result = SaasKit::billing('bkash')->initiate($tenant, 2500);
return redirect($result['redirect_url']); // redirect to bKash page

// Initiate a Nagad payment
$result = SaasKit::billing('nagad')->initiate($tenant, 2500);
return redirect($result['redirect_url']);

// Verify a payment
$confirmed = SaasKit::billing('bkash')->verify($paymentId);
```

### 7. Listen to Events

[](#7-listen-to-events)

```
// In your EventServiceProvider:
use Mahbub\SaasKit\Events\PaymentSucceeded;
use Mahbub\SaasKit\Events\UsageLimitReached;

protected $listen = [
    PaymentSucceeded::class => [
        ActivateSubscriptionListener::class,
    ],
    UsageLimitReached::class => [
        NotifyTenantListener::class,
    ],
];
```

---

🔄 Multi-Database Tenancy
------------------------

[](#-multi-database-tenancy)

Switch to multi-DB mode in config:

```
SAAS_TENANCY_DRIVER=multi
```

Each tenant gets their own database (`tenant_1`, `tenant_2`, etc.). Run tenant migrations:

```
// Run migrations on a specific tenant's database
$tenantManager->runForTenant($tenant, function () {
    Artisan::call('migrate', ['--path' => 'database/migrations/tenant']);
});
```

---

🔧 Override Models
-----------------

[](#-override-models)

You can use your own models:

```
// config/saas-kit.php
'models' => [
    'tenant'       => App\Models\Tenant::class,
    'plan'         => App\Models\Plan::class,
    'subscription' => App\Models\Subscription::class,
],
```

---

📄 License
---------

[](#-license)

The MIT License (MIT). See [LICENSE](LICENSE) for details.

---

**Made with ❤️ by [Mahbub](https://github.com/mahbub) — Dhaka, Bangladesh**

###  Health Score

39

—

LowBetter than 84% of packages

Maintenance100

Actively maintained with recent releases

Popularity0

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity42

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

1d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/277972474?v=4)[mahbubur508](/maintainers/mahbubur508)[@mahbubur508](https://github.com/mahbubur508)

---

Top Contributors

[![Mahbub2236](https://avatars.githubusercontent.com/u/94888674?v=4)](https://github.com/Mahbub2236 "Mahbub2236 (1 commits)")

---

Tags

laravelstripebillingsubscriptionsaasmultitenancybkashnagad

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/mahbub-laravel-saas-kit/health.svg)

```
[![Health](https://phpackages.com/badges/mahbub-laravel-saas-kit/health.svg)](https://phpackages.com/packages/mahbub-laravel-saas-kit)
```

###  Alternatives

[duncanmcclean/statamic-cargo

Comprehensive e-commerce addon for Statamic. Build bespoke e-commerce sites without the complexity.

3310.1k](/packages/duncanmcclean-statamic-cargo)[helori/laravel-saas

Software as a Service scaffholding for Laravel based on Vue 3, Tailwindcss and Stripe. Inspired by Laravel Jetstream and Spark.

121.3k](/packages/helori-laravel-saas)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
